From fc86c240271c2a339f373eadfd507be9f5f31507 Mon Sep 17 00:00:00 2001 From: Simon Robertshaw Date: Mon, 18 Jun 2012 15:54:55 +0100 Subject: [PATCH] Better freeing for memory in GameSave --- src/client/GameSave.cpp | 39 +++++++++++++++++---------------------- 1 file changed, 17 insertions(+), 22 deletions(-) diff --git a/src/client/GameSave.cpp b/src/client/GameSave.cpp index 46a600f01..6cc80e75f 100644 --- a/src/client/GameSave.cpp +++ b/src/client/GameSave.cpp @@ -22,6 +22,8 @@ gravityMode(save.gravityMode), airMode(save.airMode), signs(save.signs) { + blockMap, blockMapPtr, fanVelX, fanVelXPtr, fanVelY, fanVelYPtr, particles = NULL; + setSize(save.blockWidth, save.blockHeight); particlesCount = save.particlesCount; @@ -33,6 +35,7 @@ signs(save.signs) GameSave::GameSave(int width, int height) { + blockMap, blockMapPtr, fanVelX, fanVelXPtr, fanVelY, fanVelYPtr, particles = NULL; setSize(width, height); } @@ -1672,26 +1675,18 @@ fin: GameSave::~GameSave() { - if(blockWidth && blockHeight) - { - if(particles) - { - delete[] particles; - } - if(blockMap) - { - delete[] blockMapPtr; - delete[] blockMap; - } - if(fanVelX) - { - delete[] fanVelXPtr; - delete[] fanVelX; - } - if(fanVelY) - { - delete[] fanVelYPtr; - delete[] fanVelY; - } - } + if(particles) + delete[] particles; + if(blockMap) + delete[] blockMap; + if(blockMapPtr) + delete[] blockMapPtr; + if(fanVelX) + delete[] fanVelX; + if(fanVelXPtr) + delete[] fanVelXPtr; + if(fanVelY) + delete[] fanVelY; + if(fanVelYPtr) + delete[] fanVelYPtr; }