From c0c30bd305cd537203fe598ecc7d0b6713abd641 Mon Sep 17 00:00:00 2001 From: Simon Robertshaw Date: Sun, 19 Aug 2012 20:44:50 +0100 Subject: Looks like calling the destructor manually is not a good idea. diff --git a/src/client/GameSave.cpp b/src/client/GameSave.cpp index 4b94764..97bf570 100644 --- a/src/client/GameSave.cpp +++ b/src/client/GameSave.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include #include "Config.h" #include "bson/BSON.h" @@ -97,7 +98,7 @@ GameSave::GameSave(std::vector data) catch(ParseException & e) { std::cout << e.what() << std::endl; - this->~GameSave(); //Free any allocated memory + dealloc(); //Free any allocated memory throw; } Collapse(); @@ -129,7 +130,7 @@ GameSave::GameSave(std::vector data) catch(ParseException & e) { std::cout << e.what() << std::endl; - this->~GameSave(); //Free any allocated memory + dealloc(); //Free any allocated memory throw; } Collapse(); @@ -161,7 +162,7 @@ GameSave::GameSave(char * data, int dataSize) catch(ParseException & e) { std::cout << e.what() << std::endl; - this->~GameSave(); //Free any allocated memory + dealloc(); //Free any allocated memory throw; } //Collapse(); @@ -2007,20 +2008,46 @@ fin: return (char*)outputData; } -GameSave::~GameSave() +void GameSave::dealloc() { if(particles) + { delete[] particles; + particles = NULL; + } if(blockMap) + { delete[] blockMap; + blockMap = NULL; + } if(blockMapPtr) + { delete[] blockMapPtr; + blockMapPtr = NULL; + } if(fanVelX) + { delete[] fanVelX; + fanVelX = NULL; + } if(fanVelXPtr) + { delete[] fanVelXPtr; + fanVelXPtr = NULL; + } if(fanVelY) + { delete[] fanVelY; + fanVelY = NULL; + } if(fanVelYPtr) + { delete[] fanVelYPtr; + fanVelYPtr = NULL; + } +} + +GameSave::~GameSave() +{ + } diff --git a/src/client/GameSave.h b/src/client/GameSave.h index 7f8e7fc..62adc17 100644 --- a/src/client/GameSave.h +++ b/src/client/GameSave.h @@ -97,6 +97,7 @@ private: std::vector originalData; + void dealloc(); void read(char * data, int dataSize); void readOPS(char * data, int dataLength); void readPSv(char * data, int dataLength); -- cgit v0.9.2-21-gd62e