Attachment "final-84.patch" to
ticket [1251399fff]
added by
dgp
2005-08-04 05:13:49.
Index: generic/tclCompExpr.c
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tclCompExpr.c,v
retrieving revision 1.13
diff -u -r1.13 tclCompExpr.c
--- generic/tclCompExpr.c 16 Feb 2003 01:36:32 -0000 1.13
+++ generic/tclCompExpr.c 3 Aug 2005 22:09:16 -0000
@@ -286,9 +286,7 @@
* TclFinalizeCompilation --
*
* Clean up the compilation environment so it can later be
- * properly reinitialized. This procedure is called by
- * TclFinalizeCompExecEnv() in tclObj.c, which in turn is called
- * by Tcl_Finalize().
+ * properly reinitialized. This procedure is called by Tcl_Finalize().
*
* Results:
* None.
Index: generic/tclEvent.c
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tclEvent.c,v
retrieving revision 1.28.2.11
diff -u -r1.28.2.11 tclEvent.c
--- generic/tclEvent.c 24 Jun 2005 18:21:39 -0000 1.28.2.11
+++ generic/tclEvent.c 3 Aug 2005 22:09:16 -0000
@@ -833,15 +833,29 @@
* order dependencies.
*/
- TclFinalizeCompExecEnv();
+ TclFinalizeCompilation();
+ TclFinalizeExecution();
TclFinalizeEnvironment();
/*
* Finalizing the filesystem must come after anything which
* might conceivably interact with the 'Tcl_FS' API.
*/
+
TclFinalizeFilesystem();
+ /*
+ * Undo all the Tcl_ObjType registrations, and reset the master list
+ * of free Tcl_Obj's. After this returns, no more Tcl_Obj's should
+ * be allocated or freed.
+ *
+ * Note in particular that TclFinalizeObjects() must follow
+ * TclFinalizeFilesystem() because TclFinalizeFilesystem free's
+ * the Tcl_Obj that holds the path of the current working directory.
+ */
+
+ TclFinalizeObjects();
+
/*
* We must be sure the encoding finalization doesn't need
* to examine the filesystem in any way. Since it only
@@ -870,13 +884,6 @@
Tcl_SetPanicProc(NULL);
/*
- * Free synchronization objects. There really should only be one
- * thread alive at this moment.
- */
-
- TclFinalizeSynchronization();
-
- /*
* We defer unloading of packages until very late
* to avoid memory access issues. Both exit callbacks and
* synchronization variables may be stored in packages.
@@ -910,14 +917,23 @@
}
#endif
+ TclFinalizePreserve();
+
/*
- * There shouldn't be any malloc'ed memory after this.
+ * Free synchronization objects. There really should only be one
+ * thread alive at this moment.
*/
- TclFinalizePreserve();
+
+ TclFinalizeSynchronization();
+
#if defined(TCL_THREADS) && defined(USE_THREAD_ALLOC) && !defined(TCL_MEM_DEBUG) && !defined(PURIFY)
TclFinalizeThreadAlloc();
#endif
+ /*
+ * At this point, there should no longer be any ckalloc'ed memory.
+ */
+
TclFinalizeMemorySubsystem();
inFinalize = 0;
}
Index: generic/tclInt.h
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tclInt.h,v
retrieving revision 1.118.2.16
diff -u -r1.118.2.16 tclInt.h
--- generic/tclInt.h 5 Jul 2005 21:18:23 -0000 1.118.2.16
+++ generic/tclInt.h 3 Aug 2005 22:09:16 -0000
@@ -1653,7 +1653,6 @@
int objc, Tcl_Obj *CONST objv[])) ;
EXTERN void TclFinalizeAllocSubsystem _ANSI_ARGS_((void));
EXTERN void TclFinalizeAsync _ANSI_ARGS_((void));
-EXTERN void TclFinalizeCompExecEnv _ANSI_ARGS_((void));
EXTERN void TclFinalizeCompilation _ANSI_ARGS_((void));
EXTERN void TclFinalizeEncodingSubsystem _ANSI_ARGS_((void));
EXTERN void TclFinalizeEnvironment _ANSI_ARGS_((void));
@@ -1665,6 +1664,7 @@
EXTERN void TclFinalizeLock _ANSI_ARGS_((void));
EXTERN void TclFinalizeMemorySubsystem _ANSI_ARGS_((void));
EXTERN void TclFinalizeNotifier _ANSI_ARGS_((void));
+EXTERN void TclFinalizeObjects _ANSI_ARGS_((void));
EXTERN void TclFinalizePreserve _ANSI_ARGS_((void));
EXTERN void TclFinalizeSynchronization _ANSI_ARGS_((void));
EXTERN void TclFinalizeThreadData _ANSI_ARGS_((void));
Index: generic/tclObj.c
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tclObj.c,v
retrieving revision 1.42.2.10
diff -u -r1.42.2.10 tclObj.c
--- generic/tclObj.c 20 Apr 2005 16:06:17 -0000 1.42.2.10
+++ generic/tclObj.c 3 Aug 2005 22:09:17 -0000
@@ -272,23 +272,22 @@
/*
*----------------------------------------------------------------------
*
- * TclFinalizeCompExecEnv --
+ * TclFinalizeObjects --
*
- * This procedure is called by Tcl_Finalize to clean up the Tcl
- * compilation and execution environment so it can later be properly
- * reinitialized.
+ * This procedure is called by Tcl_Finalize to clean up all
+ * registered Tcl_ObjType's and to reset the tclFreeObjList.
*
* Results:
* None.
*
* Side effects:
- * Cleans up the compilation and execution environment
+ * None.
*
*----------------------------------------------------------------------
*/
void
-TclFinalizeCompExecEnv()
+TclFinalizeObjects()
{
Tcl_MutexLock(&tableMutex);
if (typeTableInitialized) {
@@ -296,12 +295,15 @@
typeTableInitialized = 0;
}
Tcl_MutexUnlock(&tableMutex);
+
+ /*
+ * All we do here is reset the head pointer of the linked list of
+ * free Tcl_Obj's to NULL; the memory finalization will take care
+ * of releasing memory for us.
+ */
Tcl_MutexLock(&tclObjMutex);
tclFreeObjList = NULL;
Tcl_MutexUnlock(&tclObjMutex);
-
- TclFinalizeCompilation();
- TclFinalizeExecution();
}
/*