Index: generic/nsfStack.c =================================================================== diff -u -rf6a37db73b3ab59faf0bd0486c19548655f98bfe -r6bc4dd9b7169c16cbc826d9071fe18a2be1f0e98 --- generic/nsfStack.c (.../nsfStack.c) (revision f6a37db73b3ab59faf0bd0486c19548655f98bfe) +++ generic/nsfStack.c (.../nsfStack.c) (revision 6bc4dd9b7169c16cbc826d9071fe18a2be1f0e98) @@ -6,13 +6,13 @@ *---------------------------------------------------------------------- * CscListAdd -- * - * Add csc entry to the list of unstack entries + * Add an entry to the list of unstacked CSC entries. * * Results: * none * * Side effects: - * list element added + * List element added * *---------------------------------------------------------------------- */ @@ -25,24 +25,28 @@ *---------------------------------------------------------------------- * CscListRemove -- * - * Remove csc entry from the list of unstack entries + * Removes an entry from the list of unstacked CSC entries. * * Results: * true on success or 0 * - * Side effects: - * list element potentially removed and freed + * Side effects: + * + * List element potentially removed and freed. If a list turns + * empty, the interp's state is updated. * *---------------------------------------------------------------------- */ static int -CscListRemove(Tcl_Interp *interp, NsfCallStackContent *cscPtr) { - NsfClasses *entryPtr; - - entryPtr = NsfClassListUnlink(&RUNTIME_STATE(interp)->cscList, cscPtr); +CscListRemove(Tcl_Interp *interp, NsfCallStackContent *cscPtr, NsfClasses **cscListPtrPtr) { + NsfClasses *entryPtr, **cscList = &RUNTIME_STATE(interp)->cscList; + entryPtr = NsfClassListUnlink(cscList, cscPtr); if (entryPtr) { FREE(NsfClasses, entryPtr); } + if (cscListPtrPtr != NULL) { + *cscListPtrPtr = *cscList; + } return (entryPtr != NULL); } #endif @@ -793,14 +797,15 @@ #if defined(CHECK_ACTIVATION_COUNTS) { int count = 0; - NsfClasses *unstackedEntries; + NsfClasses *unstackedEntries = RUNTIME_STATE(interp)->cscList, *nextCscPtr = unstackedEntries; - for (unstackedEntries = RUNTIME_STATE(interp)->cscList; - unstackedEntries; - unstackedEntries = unstackedEntries->nextPtr, count ++) { - NsfCallStackContent *cscPtr = (NsfCallStackContent *)unstackedEntries->cl; - CscListRemove(interp, cscPtr); + while (nextCscPtr) { + NsfCallStackContent *cscPtr = (NsfCallStackContent *)nextCscPtr->cl; + CscListRemove(interp, cscPtr, &unstackedEntries); CscFinish(interp, cscPtr, TCL_OK, "unwind"); + + count ++; + nextCscPtr = unstackedEntries ? unstackedEntries->nextPtr : NULL; } if (count>0 && RUNTIME_STATE(interp)->debugLevel > 0) {