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
This commit is contained in:
Max Horn 2010-10-30 00:33:31 +00:00
parent 55a8bd9e35
commit afb5986c9e

View File

@ -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;