summaryrefslogtreecommitdiff
path: root/src/gamelog.cpp
diff options
context:
space:
mode:
authorsmatz <smatz@openttd.org>2012-02-05 15:51:13 +0000
committersmatz <smatz@openttd.org>2012-02-05 15:51:13 +0000
commiteb015cbfb62451313d99fa4829d9a712411bf002 (patch)
tree06901fd370a91bd16bd32d94dd0841ceadfe3a9c /src/gamelog.cpp
parentfbf29d5da8bc8f76c5f0c205adda7b071f439ab3 (diff)
downloadopenttd-eb015cbfb62451313d99fa4829d9a712411bf002.tar.xz
(svn r23901) -Fix: memory leak everytime one clicked a savegame in the load GUI
Diffstat (limited to 'src/gamelog.cpp')
-rw-r--r--src/gamelog.cpp21
1 files changed, 14 insertions, 7 deletions
diff --git a/src/gamelog.cpp b/src/gamelog.cpp
index f4f009166..b4b9fd7a6 100644
--- a/src/gamelog.cpp
+++ b/src/gamelog.cpp
@@ -64,14 +64,12 @@ void GamelogStopAction()
}
/**
- * Resets and frees all memory allocated - used before loading or starting a new game
+ * Frees the memory allocated by a gamelog
*/
-void GamelogReset()
+void GamelogFree(LoggedAction *gamelog_action, uint gamelog_actions)
{
- assert(_gamelog_action_type == GLAT_NONE);
-
- for (uint i = 0; i < _gamelog_actions; i++) {
- const LoggedAction *la = &_gamelog_action[i];
+ for (uint i = 0; i < gamelog_actions; i++) {
+ const LoggedAction *la = &gamelog_action[i];
for (uint j = 0; j < la->changes; j++) {
const LoggedChange *lc = &la->change[j];
if (lc->ct == GLCT_SETTING) free(lc->setting.name);
@@ -79,7 +77,16 @@ void GamelogReset()
free(la->change);
}
- free(_gamelog_action);
+ free(gamelog_action);
+}
+
+/**
+ * Resets and frees all memory allocated - used before loading or starting a new game
+ */
+void GamelogReset()
+{
+ assert(_gamelog_action_type == GLAT_NONE);
+ GamelogFree(_gamelog_action, _gamelog_actions);
_gamelog_action = NULL;
_gamelog_actions = 0;