diff options
author | Johannes Schickel | 2009-05-31 12:28:56 +0000 |
---|---|---|
committer | Johannes Schickel | 2009-05-31 12:28:56 +0000 |
commit | f59176cd4632b363f5531034b7bbd6628d831118 (patch) | |
tree | 913a4c87cd7b391f7230bb7920de5dca761f3fc8 /engines | |
parent | e317012cce8647a9d50f185cdba5bafc7c48c9a2 (diff) | |
download | scummvm-rg350-f59176cd4632b363f5531034b7bbd6628d831118.tar.gz scummvm-rg350-f59176cd4632b363f5531034b7bbd6628d831118.tar.bz2 scummvm-rg350-f59176cd4632b363f5531034b7bbd6628d831118.zip |
Fix various memory leaks in Lands of Lore.
svn-id: r41066
Diffstat (limited to 'engines')
-rw-r--r-- | engines/kyra/lol.cpp | 3 | ||||
-rw-r--r-- | engines/kyra/script_lol.cpp | 2 | ||||
-rw-r--r-- | engines/kyra/staticres.cpp | 15 |
3 files changed, 13 insertions, 7 deletions
diff --git a/engines/kyra/lol.cpp b/engines/kyra/lol.cpp index c0fe0f3f69..0ff8470ce3 100644 --- a/engines/kyra/lol.cpp +++ b/engines/kyra/lol.cpp @@ -408,6 +408,9 @@ LoLEngine::~LoLEngine() { for (Common::List<Audio::AudioStream *>::iterator i = _speechList.begin(); i != _speechList.end(); ++i) delete *i; _speechList.clear(); + + _emc->unload(&_itemScript); + _emc->unload(&_scriptData); } Screen *LoLEngine::screen() { diff --git a/engines/kyra/script_lol.cpp b/engines/kyra/script_lol.cpp index 1e5740dfc3..274a852066 100644 --- a/engines/kyra/script_lol.cpp +++ b/engines/kyra/script_lol.cpp @@ -39,6 +39,7 @@ void LoLEngine::runInitScript(const char *filename, int optionalFunc) { EMCData scriptData; EMCState scriptState; memset(&scriptData, 0, sizeof(EMCData)); + _emc->unload(&_scriptData); _emc->load(filename, &scriptData, &_opcodes); _emc->init(&scriptState, &scriptData); @@ -58,6 +59,7 @@ void LoLEngine::runInitScript(const char *filename, int optionalFunc) { } void LoLEngine::runInfScript(const char *filename) { + _emc->unload(&_scriptData); _emc->load(filename, &_scriptData, &_opcodes); runLevelScript(0x400, -1); } diff --git a/engines/kyra/staticres.cpp b/engines/kyra/staticres.cpp index b30b3b70f1..6c4985d608 100644 --- a/engines/kyra/staticres.cpp +++ b/engines/kyra/staticres.cpp @@ -1031,8 +1031,8 @@ bool StaticResource::loadCharData(const char *filename, void *&ptr, int &size) { t->characterUpdateDelay[ii] = file->readByte(); }; + delete file; ptr = charData; - return true; } @@ -1060,8 +1060,8 @@ bool StaticResource::loadSpellData(const char *filename, void *&ptr, int &size) t->flags = file->readUint16LE(); }; + delete file; ptr = spellData; - return true; } @@ -1082,8 +1082,9 @@ bool StaticResource::loadCompassData(const char *filename, void *&ptr, int &size t->flags = file->readByte(); }; - ptr = defs; + delete file; + ptr = defs; return true; } @@ -1105,8 +1106,8 @@ bool StaticResource::loadFlyingObjectData(const char *filename, void *&ptr, int t->flipFlags = file->readByte(); }; + delete file; ptr = defs; - return true; } @@ -1123,8 +1124,8 @@ bool StaticResource::loadRawDataBe16(const char *filename, void *&ptr, int &size for (int i = 0; i < size; i++) r[i] = file->readUint16BE(); + delete file; ptr = r; - return true; } @@ -1141,8 +1142,8 @@ bool StaticResource::loadRawDataBe32(const char *filename, void *&ptr, int &size for (int i = 0; i < size; i++) r[i] = file->readUint32BE(); + delete file; ptr = r; - return true; } @@ -1168,8 +1169,8 @@ bool StaticResource::loadButtonDefs(const char *filename, void *&ptr, int &size) r[i].screenDim = file->readUint16BE(); } + delete file; ptr = r; - return true; } #endif // ENABLE_LOL |