[Scummvm-cvs-logs] scummvm master -> 6318758e7119d7834a9f7c4be11b819ee0bfaff4
fuzzie
fuzzie at fuzzie.org
Mon Jun 20 17:47:34 CEST 2011
This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
0269a8d900 TINSEL: Fix/comment CORO_KILL_SELF macro.
6318758e71 TINSEL: Don't leak running processes in Scheduler::reset().
Commit: 0269a8d9008f51cca63ad215bbb2aa23ad75d574
https://github.com/scummvm/scummvm/commit/0269a8d9008f51cca63ad215bbb2aa23ad75d574
Author: Alyssa Milburn (fuzzie at fuzzie.org)
Date: 2011-06-20T08:23:30-07:00
Commit Message:
TINSEL: Fix/comment CORO_KILL_SELF macro.
This reverts 9573b1d2f54818f9bdac4a91e0a90b306ade7810, which changed
the behaviour of (among other things) NewScene, which made Discworld
uncompletable. Thanks to digitall for bisection/reproduction.
Changed paths:
engines/tinsel/coroutine.h
diff --git a/engines/tinsel/coroutine.h b/engines/tinsel/coroutine.h
index b62c40b..5bcf114 100644
--- a/engines/tinsel/coroutine.h
+++ b/engines/tinsel/coroutine.h
@@ -178,10 +178,15 @@ public:
#define CORO_RESCHEDULE do { g_scheduler->reschedule(); CORO_SLEEP(1); } while (0)
/**
- * Stop the currently running coroutine.
+ * Stop the currently running coroutine and all calling coroutines.
+ *
+ * This sets _sleep to -1 rather than 0 so that the context doesn't get
+ * deleted by CoroContextHolder, since we want CORO_INVOKE_ARGS to
+ * propogate the _sleep value and return immediately (the scheduler will
+ * then delete the entire coroutine's state, including all subcontexts).
*/
#define CORO_KILL_SELF() \
- do { if (&coroParam != &nullContext) { coroParam->_sleep = 0; } return; } while (0)
+ do { if (&coroParam != &nullContext) { coroParam->_sleep = -1; } return; } while (0)
/**
@@ -193,8 +198,12 @@ public:
/**
* Invoke another coroutine.
*
- * What makes this tricky is that the coroutine we called my yield/sleep,
- * and we need to deal with this adequately.
+ * If the subcontext still exists after the coroutine is invoked, it has
+ * either yielded/slept or killed itself, and so we copy the _sleep value
+ * to our own context and return (execution will continue at the case
+ * statement below, where we loop and call the coroutine again).
+ * If the subcontext is null, the coroutine ended normally, and we can
+ * simply break out of the loop and continue execution.
*
* @param subCoro name of the coroutine-enabled function to invoke
* @param ARGS list of arguments to pass to subCoro
Commit: 6318758e7119d7834a9f7c4be11b819ee0bfaff4
https://github.com/scummvm/scummvm/commit/6318758e7119d7834a9f7c4be11b819ee0bfaff4
Author: Alyssa Milburn (fuzzie at fuzzie.org)
Date: 2011-06-20T08:42:00-07:00
Commit Message:
TINSEL: Don't leak running processes in Scheduler::reset().
Changed paths:
engines/tinsel/sched.cpp
diff --git a/engines/tinsel/sched.cpp b/engines/tinsel/sched.cpp
index b24d6bf..d6cd806 100644
--- a/engines/tinsel/sched.cpp
+++ b/engines/tinsel/sched.cpp
@@ -70,6 +70,7 @@ Scheduler::Scheduler() {
active = new PROCESS;
active->pPrevious = NULL;
+ active->pNext = NULL;
g_scheduler = this; // FIXME HACK
}
@@ -113,6 +114,14 @@ void Scheduler::reset() {
memset(processList, 'S', MAX_PROCESSES * sizeof(PROCESS));
}
+ // 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;
+ }
+
// no active processes
pCurrent = active->pNext = NULL;
More information about the Scummvm-git-logs
mailing list