From afb5986c9eaf172d2a00530012702f7054e95521 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Sat, 30 Oct 2010 00:33:31 +0000 Subject: 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 --- engines/tinsel/sched.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'engines/tinsel/sched.cpp') 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; -- cgit v1.2.3