aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Gilbert2009-10-10 04:15:38 +0000
committerPaul Gilbert2009-10-10 04:15:38 +0000
commitdf3fbd432de3d0bfc8ec689a5616b34103c63791 (patch)
tree4dea186e6dabb0463adf7f64d8eeedd5c8ff7219
parent6c1cac39567bf6867274c1bb0c93feef72d535c6 (diff)
downloadscummvm-rg350-df3fbd432de3d0bfc8ec689a5616b34103c63791.tar.gz
scummvm-rg350-df3fbd432de3d0bfc8ec689a5616b34103c63791.tar.bz2
scummvm-rg350-df3fbd432de3d0bfc8ec689a5616b34103c63791.zip
Further memory leak fixes
svn-id: r44861
-rw-r--r--engines/cruise/cruise_main.cpp12
-rw-r--r--engines/cruise/dataLoader.cpp2
-rw-r--r--engines/cruise/function.cpp3
-rw-r--r--engines/cruise/overlay.cpp2
-rw-r--r--engines/cruise/sound.cpp6
5 files changed, 20 insertions, 5 deletions
diff --git a/engines/cruise/cruise_main.cpp b/engines/cruise/cruise_main.cpp
index e3e5b4c98d..6f5bf552fa 100644
--- a/engines/cruise/cruise_main.cpp
+++ b/engines/cruise/cruise_main.cpp
@@ -211,6 +211,17 @@ void resetPtr2(scriptInstanceStruct *ptr) {
}
void resetActorPtr(actorStruct *ptr) {
+ actorStruct *p = ptr;
+
+ if (p->next) {
+ p = p->next;
+ do {
+ actorStruct *pNext = p->next;
+ MemFree(p);
+ p = pNext;
+ } while (p);
+ }
+
ptr->next = NULL;
ptr->prev = NULL;
}
@@ -1983,6 +1994,7 @@ void CruiseEngine::mainLoop(void) {
// Free data
removeAllScripts(&relHead);
removeAllScripts(&procHead);
+ resetActorPtr(&actorHead);
freeOverlayTable();
closeCnf();
closeBase();
diff --git a/engines/cruise/dataLoader.cpp b/engines/cruise/dataLoader.cpp
index 44946890db..24365e0888 100644
--- a/engines/cruise/dataLoader.cpp
+++ b/engines/cruise/dataLoader.cpp
@@ -307,6 +307,8 @@ int loadFileRange(const char *name, int startIdx, int currentEntryIdx, int numId
error("Unknown fileType in loadFileRange");
}
+ MemFree(ptr);
+
return 0;
}
diff --git a/engines/cruise/function.cpp b/engines/cruise/function.cpp
index 8e112ef804..4c1ab63a8a 100644
--- a/engines/cruise/function.cpp
+++ b/engines/cruise/function.cpp
@@ -276,7 +276,8 @@ void freeObjectList(cellStruct *pListHead) {
cellStruct *pNext = pCurrent->next;
if (pCurrent->freeze == 0) {
- MemFree(pCurrent->gfxPtr);
+ if (pCurrent->gfxPtr)
+ freeGfx(pCurrent->gfxPtr);
MemFree(pCurrent);
}
diff --git a/engines/cruise/overlay.cpp b/engines/cruise/overlay.cpp
index 5bf1fd97fa..085f8b25c4 100644
--- a/engines/cruise/overlay.cpp
+++ b/engines/cruise/overlay.cpp
@@ -113,6 +113,8 @@ int freeOverlay(int overlayIdx) {
MemFree(ovlDataPtr->arrayStates);
MemFree(ovlDataPtr->nameVerbGlob);
MemFree(ovlDataPtr->arrayNameObj);
+ MemFree(ovlDataPtr->arrayRelocGlob);
+ MemFree(ovlDataPtr->arrayNameRelocGlob);
MemFree(ovlDataPtr);
overlayTable[overlayIdx].ovlData = NULL;
diff --git a/engines/cruise/sound.cpp b/engines/cruise/sound.cpp
index 811cbd4523..4985dd3ef8 100644
--- a/engines/cruise/sound.cpp
+++ b/engines/cruise/sound.cpp
@@ -601,9 +601,7 @@ PCSoundFxPlayer::PCSoundFxPlayer(PCSoundDriver *driver)
PCSoundFxPlayer::~PCSoundFxPlayer() {
_driver->setUpdateCallback(NULL, NULL);
- if (_playing) {
- stop();
- }
+ stop();
}
bool PCSoundFxPlayer::load(const char *song) {
@@ -674,8 +672,8 @@ void PCSoundFxPlayer::stop() {
_driver->stopChannel(i);
}
_driver->stopAll();
- unload();
}
+ unload();
}
void PCSoundFxPlayer::fadeOut() {