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) if(particles)
{
delete[] particles; delete[] particles;
}
if(blockMap) if(blockMap)
{
delete[] blockMapPtr;
delete[] blockMap; delete[] blockMap;
} if(blockMapPtr)
delete[] blockMapPtr;
if(fanVelX) if(fanVelX)
{
delete[] fanVelXPtr;
delete[] fanVelX; delete[] fanVelX;
} if(fanVelXPtr)
delete[] fanVelXPtr;
if(fanVelY) if(fanVelY)
{
delete[] fanVelYPtr;
delete[] fanVelY; delete[] fanVelY;
} if(fanVelYPtr)
} delete[] fanVelYPtr;
} }