aboutsummaryrefslogtreecommitdiff
path: root/engines/tinsel/sched.cpp
diff options
context:
space:
mode:
authorMax Horn2010-10-30 00:33:31 +0000
committerMax Horn2010-10-30 00:33:31 +0000
commitafb5986c9eaf172d2a00530012702f7054e95521 (patch)
tree594808e19efacc2b1bcecfca7281ebf2d106792c /engines/tinsel/sched.cpp
parent55a8bd9e359074709975e6b99629fbb3cae4a913 (diff)
downloadscummvm-rg350-afb5986c9eaf172d2a00530012702f7054e95521.tar.gz
scummvm-rg350-afb5986c9eaf172d2a00530012702f7054e95521.tar.bz2
scummvm-rg350-afb5986c9eaf172d2a00530012702f7054e95521.zip
TINSEL: Dispose state of active coroutines in Scheduler destructor
This fixes some leaks that occurred when exiting the game resp. returning to launcher. Note that we still leak some coroutines when exiting after loading a savegame. svn-id: r53933
Diffstat (limited to 'engines/tinsel/sched.cpp')
-rw-r--r--engines/tinsel/sched.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/engines/tinsel/sched.cpp b/engines/tinsel/sched.cpp
index d8a44944fc..b1de9d4ae5 100644
--- a/engines/tinsel/sched.cpp
+++ b/engines/tinsel/sched.cpp
@@ -77,6 +77,14 @@ Scheduler::Scheduler() {
}
Scheduler::~Scheduler() {
+ // Kill all running processes (i.e. free memory allocated for their state).
+ PROCESS *pProc = active->pNext;
+ while (pProc != NULL) {
+ delete pProc->state;
+ pProc->state = 0;
+ pProc = pProc->pNext;
+ }
+
free(processList);
processList = NULL;
@@ -392,6 +400,7 @@ void Scheduler::killProcess(PROCESS *pKillProc) {
(pRCfunction)(pKillProc);
delete pKillProc->state;
+ pKillProc->state = 0;
// Take the process out of the active chain list
pKillProc->pPrevious->pNext = pKillProc->pNext;
@@ -458,6 +467,7 @@ int Scheduler::killMatchingProcess(int pidKill, int pidMask) {
(pRCfunction)(pProc);
delete pProc->state;
+ pProc->state = 0;
// make prev point to next to unlink pProc
pPrev->pNext = pProc->pNext;