memory: use proper delete[]
parent
c547d11cd5
commit
0baa2eb649
|
@ -75,6 +75,8 @@ public:
|
||||||
const auto &end = std::prev(treemap.end());
|
const auto &end = std::prev(treemap.end());
|
||||||
|
|
||||||
*length = end->first;
|
*length = end->first;
|
||||||
|
if(*length == 0) return nullptr;
|
||||||
|
|
||||||
// std::cout << "Length: " << *length << "\n";
|
// std::cout << "Length: " << *length << "\n";
|
||||||
V *arr{new V[*length]};
|
V *arr{new V[*length]};
|
||||||
|
|
||||||
|
|
|
@ -41,11 +41,12 @@ void mesh(Chunk::Chunk* chunk)
|
||||||
indices.clear();
|
indices.clear();
|
||||||
vIndex = 0;
|
vIndex = 0;
|
||||||
|
|
||||||
if(chunk->getState(Chunk::CHUNK_STATE_EMPTY)) return;
|
// if(chunk->getState(Chunk::CHUNK_STATE_EMPTY)) return;
|
||||||
|
|
||||||
// convert tree to array since it is easier to work with it
|
// convert tree to array since it is easier to work with it
|
||||||
int length{0};
|
int length{0};
|
||||||
Block *blocks = chunk->getBlocksArray(&length);
|
Block *blocks = chunk->getBlocksArray(&length);
|
||||||
|
if(length == 0) return;
|
||||||
|
|
||||||
int k, l, u, v, w, h, n, j, i;
|
int k, l, u, v, w, h, n, j, i;
|
||||||
int x[]{0, 0, 0};
|
int x[]{0, 0, 0};
|
||||||
|
@ -182,9 +183,6 @@ void mesh(Chunk::Chunk* chunk)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (blocks)
|
|
||||||
delete blocks;
|
|
||||||
|
|
||||||
if (vIndex > 0)
|
if (vIndex > 0)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -216,6 +214,7 @@ void mesh(Chunk::Chunk* chunk)
|
||||||
indices.clear();
|
indices.clear();
|
||||||
colors.clear();
|
colors.clear();
|
||||||
}
|
}
|
||||||
|
delete[] blocks;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue