diff options
author | Eugenio Favalli <elvenprogrammer@gmail.com> | 2005-09-18 20:22:07 +0000 |
---|---|---|
committer | Eugenio Favalli <elvenprogrammer@gmail.com> | 2005-09-18 20:22:07 +0000 |
commit | 89dbeaaee05a6ce7adc353f5676df211c1ed83fb (patch) | |
tree | 3f18e18af0248ae555d90f48f0217d3c5371505a /src | |
parent | 761c274a741869ef767d0db2cd8ef0eca149ce3d (diff) | |
download | mana-89dbeaaee05a6ce7adc353f5676df211c1ed83fb.tar.gz mana-89dbeaaee05a6ce7adc353f5676df211c1ed83fb.tar.bz2 mana-89dbeaaee05a6ce7adc353f5676df211c1ed83fb.tar.xz mana-89dbeaaee05a6ce7adc353f5676df211c1ed83fb.zip |
Applyed biggeruniverse's patch to fix memory leaks.
Diffstat (limited to 'src')
-rw-r--r-- | src/game.cpp | 12 | ||||
-rw-r--r-- | src/gui/gui.cpp | 1 | ||||
-rw-r--r-- | src/gui/updatewindow.cpp | 3 | ||||
-rw-r--r-- | src/main.cpp | 2 | ||||
-rw-r--r-- | src/resources/mapreader.cpp | 9 |
5 files changed, 19 insertions, 8 deletions
diff --git a/src/game.cpp b/src/game.cpp index 88990ee1..95c502c3 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -88,6 +88,7 @@ int fps = 0, frame = 0, current_npc = 0; bool displayPathToMouse = false; unsigned short startX = 0, startY = 0; Being *autoTarget = NULL; +Map *tiledMap = NULL; Engine *engine = NULL; SDL_Joystick *joypad = NULL; /**< Joypad object */ @@ -405,14 +406,17 @@ void game() do_parse(); flush(); } + + do_exit(); +} +void do_exit() +{ delete engine; + delete tiledMap; destroyGuiWindows(); close_session(); -} -void do_exit() -{ if (joypad != NULL) { SDL_JoystickClose(joypad); @@ -920,7 +924,7 @@ void do_input() Direction = Being::NE; } - Map *tiledMap = engine->getCurrentMap(); + tiledMap = engine->getCurrentMap(); // Allow keyboard control to interrupt an existing path if ((xDirection != 0 || yDirection != 0) && player_node->action == Being::WALK) diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index 3642b004..6edcd1a4 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -181,6 +181,7 @@ Gui::~Gui() } delete mGuiFont; + delete speechFont; delete mTop; delete mImageLoader; diff --git a/src/gui/updatewindow.cpp b/src/gui/updatewindow.cpp index e0c098f0..81ae885c 100644 --- a/src/gui/updatewindow.cpp +++ b/src/gui/updatewindow.cpp @@ -110,7 +110,8 @@ UpdaterWindow::~UpdaterWindow() remove((mBasePath + "/updates/resources.txt").c_str()); remove((mBasePath + "/updates/download.temp").c_str()); - delete mCurlError; + delete [] mCurlError; + delete mScrollArea; delete mLabel; delete mProgressBar; delete mCancelButton; diff --git a/src/main.cpp b/src/main.cpp index c176819a..0f94db54 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -302,6 +302,8 @@ void exit_engine() config.write(); delete gui; delete graphics; + delete hairset; + delete playerset; // Shutdown libxml xmlCleanupParser(); diff --git a/src/resources/mapreader.cpp b/src/resources/mapreader.cpp index 5e83f34f..b5b1a142 100644 --- a/src/resources/mapreader.cpp +++ b/src/resources/mapreader.cpp @@ -129,6 +129,7 @@ Map *MapReader::readMap(const std::string &filename) ResourceManager *resman = ResourceManager::getInstance(); int fileSize; void *buffer = resman->loadFile(filename, fileSize); + Map *map = NULL; if (buffer == NULL) { @@ -175,14 +176,16 @@ Map *MapReader::readMap(const std::string &filename) logger->log("Error: Not a map file (%s)!", filename.c_str()); return NULL; } - - return readMap(node, filename); + else + { + map = readMap(node, filename); + } xmlFreeDoc(doc); } else { logger->log("Error while parsing map file (%s)!", filename.c_str()); } - return NULL; + return map; } Map* MapReader::readMap(xmlNodePtr node, const std::string &path) |