Better freeing for memory in GameSave

This commit is contained in:
Simon Robertshaw
2012-06-18 15:54:55 +01:00
parent 81423ba568
commit fc86c24027

View File

@@ -22,6 +22,8 @@ gravityMode(save.gravityMode),
airMode(save.airMode), airMode(save.airMode),
signs(save.signs) signs(save.signs)
{ {
blockMap, blockMapPtr, fanVelX, fanVelXPtr, fanVelY, fanVelYPtr, particles = NULL;
setSize(save.blockWidth, save.blockHeight); setSize(save.blockWidth, save.blockHeight);
particlesCount = save.particlesCount; particlesCount = save.particlesCount;
@@ -33,6 +35,7 @@ signs(save.signs)
GameSave::GameSave(int width, int height) GameSave::GameSave(int width, int height)
{ {
blockMap, blockMapPtr, fanVelX, fanVelXPtr, fanVelY, fanVelYPtr, particles = NULL;
setSize(width, height); setSize(width, height);
} }
@@ -1672,26 +1675,18 @@ fin:
GameSave::~GameSave() GameSave::~GameSave()
{ {
if(blockWidth && blockHeight) if(particles)
{ delete[] particles;
if(particles) if(blockMap)
{ delete[] blockMap;
delete[] particles; if(blockMapPtr)
} delete[] blockMapPtr;
if(blockMap) if(fanVelX)
{ delete[] fanVelX;
delete[] blockMapPtr; if(fanVelXPtr)
delete[] blockMap; delete[] fanVelXPtr;
} if(fanVelY)
if(fanVelX) delete[] fanVelY;
{ if(fanVelYPtr)
delete[] fanVelXPtr; delete[] fanVelYPtr;
delete[] fanVelX;
}
if(fanVelY)
{
delete[] fanVelYPtr;
delete[] fanVelY;
}
}
} }