[Scummvm-cvs-logs] SF.net SVN: scummvm:[38933] scummvm/trunk/engines/sci/engine
wjpalenstijn at users.sourceforge.net
wjpalenstijn at users.sourceforge.net
Fri Feb 27 20:38:20 CET 2009
Revision: 38933
http://scummvm.svn.sourceforge.net/scummvm/?rev=38933&view=rev
Author: wjpalenstijn
Date: 2009-02-27 19:38:20 +0000 (Fri, 27 Feb 2009)
Log Message:
-----------
fix warnings and memleaks in savegame.cfsml
Modified Paths:
--------------
scummvm/trunk/engines/sci/engine/savegame.cfsml
scummvm/trunk/engines/sci/engine/savegame.cpp
scummvm/trunk/engines/sci/engine/seg_manager.cpp
scummvm/trunk/engines/sci/engine/state.h
scummvm/trunk/engines/sci/engine/vm.h
Modified: scummvm/trunk/engines/sci/engine/savegame.cfsml
===================================================================
--- scummvm/trunk/engines/sci/engine/savegame.cfsml 2009-02-27 19:37:29 UTC (rev 38932)
+++ scummvm/trunk/engines/sci/engine/savegame.cfsml 2009-02-27 19:38:20 UTC (rev 38933)
@@ -737,9 +737,9 @@
SavegameMetadata *meta = new SavegameMetadata;
meta->savegame_version = FREESCI_CURRENT_SAVEGAME_VERSION;
- meta->savegame_name = savename;
+ meta->savegame_name = sci_strdup(savename);
meta->version = s->version;
- meta->game_version = s->game_version;
+ meta->game_version = sci_strdup(s->game_version);
meta->savegame_date = ((curTime.tm_mday & 0xFF) << 24) | (((curTime.tm_mon + 1) & 0xFF) << 16) | ((curTime.tm_year + 1900) & 0xFFFF);
meta->savegame_time = ((curTime.tm_hour & 0xFF) << 16) | (((curTime.tm_min) & 0xFF) << 8) | ((curTime.tm_sec) & 0xFF);
fprintf(stderr, "date/time: %d %d\n", meta->savegame_date, meta->savegame_time);
Modified: scummvm/trunk/engines/sci/engine/savegame.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/savegame.cpp 2009-02-27 19:37:29 UTC (rev 38932)
+++ scummvm/trunk/engines/sci/engine/savegame.cpp 2009-02-27 19:38:20 UTC (rev 38933)
@@ -4791,9 +4791,9 @@
SavegameMetadata *meta = new SavegameMetadata;
meta->savegame_version = FREESCI_CURRENT_SAVEGAME_VERSION;
- meta->savegame_name = savename;
+ meta->savegame_name = sci_strdup(savename);
meta->version = s->version;
- meta->game_version = s->game_version;
+ meta->game_version = sci_strdup(s->game_version);
meta->savegame_date = ((curTime.tm_mday & 0xFF) << 24) | (((curTime.tm_mon + 1) & 0xFF) << 16) | ((curTime.tm_year + 1900) & 0xFFFF);
meta->savegame_time = ((curTime.tm_hour & 0xFF) << 16) | (((curTime.tm_min) & 0xFF) << 8) | ((curTime.tm_sec) & 0xFF);
fprintf(stderr, "date/time: %d %d\n", meta->savegame_date, meta->savegame_time);
Modified: scummvm/trunk/engines/sci/engine/seg_manager.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/seg_manager.cpp 2009-02-27 19:37:29 UTC (rev 38932)
+++ scummvm/trunk/engines/sci/engine/seg_manager.cpp 2009-02-27 19:38:20 UTC (rev 38933)
@@ -252,8 +252,9 @@
break;
case MEM_OBJ_DYNMEM:
- if (mobj->data.dynmem.buf)
- free(mobj->data.dynmem.buf);
+ free(mobj->data.dynmem.description);
+ mobj->data.dynmem.description = NULL;
+ free(mobj->data.dynmem.buf);
mobj->data.dynmem.buf = NULL;
break;
case MEM_OBJ_SYS_STRINGS:
@@ -1398,7 +1399,7 @@
else
mobj->data.dynmem.buf = (byte*) sci_malloc(size);
- mobj->data.dynmem.description = descr;
+ mobj->data.dynmem.description = sci_strdup(descr);
return (unsigned char *)(mobj->data.dynmem.buf);
}
Modified: scummvm/trunk/engines/sci/engine/state.h
===================================================================
--- scummvm/trunk/engines/sci/engine/state.h 2009-02-27 19:37:29 UTC (rev 38932)
+++ scummvm/trunk/engines/sci/engine/state.h 2009-02-27 19:38:20 UTC (rev 38933)
@@ -86,7 +86,9 @@
// Savegame metadata
struct SavegameMetadata {
- const char *savegame_name;
+ SavegameMetadata() : savegame_name(0), game_version(0) { }
+ ~SavegameMetadata() { free(savegame_name); free(game_version); }
+ char *savegame_name;
int savegame_version;
char *game_version;
sci_version_t version;
Modified: scummvm/trunk/engines/sci/engine/vm.h
===================================================================
--- scummvm/trunk/engines/sci/engine/vm.h 2009-02-27 19:37:29 UTC (rev 38932)
+++ scummvm/trunk/engines/sci/engine/vm.h 2009-02-27 19:38:20 UTC (rev 38933)
@@ -267,7 +267,7 @@
struct dynmem_t {
int size;
- const char *description;
+ char *description;
byte *buf;
}; /* Free-style memory */
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list