Fix memory leak on vertices allocations

This commit is contained in:
JackCarterSmith 2024-12-01 22:28:42 +01:00
parent 5d20018fae
commit 2031e1a4c4
Signed by: JackCarterSmith
GPG Key ID: 832E52F4E23F8F24

View File

@ -120,7 +120,7 @@ void Graphic3DRenderer::Draw(sf::RenderTexture& context) {
{
size_t vCount = obj->GetObjectVerticesCount();
auto& oMesh = obj->GetObjectMesh();
M3D_F4* projVertices = new M3D_F4[vCount];
auto* projVertices = new M3D_F4[vCount];
// Vertices homogeneous clip space transformation
M3D_V3Transform(
@ -131,7 +131,7 @@ void Graphic3DRenderer::Draw(sf::RenderTexture& context) {
);
// Draw the object indice triangles if visible or partially clipped
sf::Vertex v_tri[4];
auto* v_tri = new sf::Vertex[4];
for (auto& objPt : oMesh.parts) {
auto indicePtr = static_cast<const uint32_t*>(objPt.indices.data());
@ -189,7 +189,8 @@ void Graphic3DRenderer::Draw(sf::RenderTexture& context) {
}
}
std::destroy_at(projVertices);
delete[] v_tri;
delete[] projVertices;
}
}
}