diff options
Diffstat (limited to 'generic')
-rw-r--r-- | generic/tclEvent.c | 6 | ||||
-rw-r--r-- | generic/tclInt.h | 4 | ||||
-rwxr-xr-x | generic/tclThreadAlloc.c | 62 |
3 files changed, 67 insertions, 5 deletions
diff --git a/generic/tclEvent.c b/generic/tclEvent.c index b169196..187a6e3 100644 --- a/generic/tclEvent.c +++ b/generic/tclEvent.c @@ -12,7 +12,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclEvent.c,v 1.43 2004/07/15 20:04:38 vasiljevic Exp $ + * RCS: @(#) $Id: tclEvent.c,v 1.44 2004/07/21 01:45:44 hobbs Exp $ */ #include "tclInt.h" @@ -973,7 +973,9 @@ Tcl_Finalize() /* * There shouldn't be any malloc'ed memory after this. */ - +#if defined(TCL_THREADS) && defined(USE_THREAD_ALLOC) + TclFinalizeThreadAlloc(); +#endif TclFinalizeMemorySubsystem(); inFinalize = 0; } diff --git a/generic/tclInt.h b/generic/tclInt.h index f3db00e..0c5d431 100644 --- a/generic/tclInt.h +++ b/generic/tclInt.h @@ -12,7 +12,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclInt.h,v 1.169 2004/07/21 00:42:38 kennykb Exp $ + * RCS: @(#) $Id: tclInt.h,v 1.170 2004/07/21 01:45:44 hobbs Exp $ */ #ifndef _TCLINT @@ -2363,6 +2363,8 @@ EXTERN void TclThreadFreeObj _ANSI_ARGS_((Tcl_Obj *)); EXTERN Tcl_Mutex *TclpNewAllocMutex _ANSI_ARGS_((void)); EXTERN void *TclpGetAllocCache _ANSI_ARGS_((void)); EXTERN void TclpSetAllocCache _ANSI_ARGS_((void *)); +EXTERN void TclFinalizeThreadAlloc _ANSI_ARGS_((void)); +EXTERN void TclpFreeAllocMutex _ANSI_ARGS_((Tcl_Mutex* mutex)); # define TclAllocObjStorage(objPtr) \ (objPtr) = TclThreadAllocObj() diff --git a/generic/tclThreadAlloc.c b/generic/tclThreadAlloc.c index 8f2b336..553bd4f 100755 --- a/generic/tclThreadAlloc.c +++ b/generic/tclThreadAlloc.c @@ -11,7 +11,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclThreadAlloc.c,v 1.13 2004/06/21 08:54:34 dkf Exp $ + * RCS: @(#) $Id: tclThreadAlloc.c,v 1.14 2004/07/21 01:45:44 hobbs Exp $ */ #include "tclInt.h" @@ -631,7 +631,7 @@ Tcl_GetMemoryInfo(dsPtr) if (cachePtr == sharedPtr) { Tcl_DStringAppendElement(dsPtr, "shared"); } else { - sprintf(buf, "thread%d", (int) cachePtr->owner); + sprintf(buf, "thread%p", cachePtr->owner); Tcl_DStringAppendElement(dsPtr, buf); } for (n = 0; n < NBUCKETS; ++n) { @@ -957,4 +957,62 @@ GetBlocks(cachePtr, bucket) return 1; } +/* + *---------------------------------------------------------------------- + * + * TclFinalizeThreadAlloc -- + * + * This procedure is used to destroy all private resources used in + * this file. + * + * Results: + * None. + * + * Side effects: + * None. + * + *---------------------------------------------------------------------- + */ + +void +TclFinalizeThreadAlloc() +{ + int i; + for (i = 0; i < NBUCKETS; ++i) { + TclpFreeAllocMutex(bucketInfo[i].lockPtr); + bucketInfo[i].lockPtr = NULL; + } + + TclpFreeAllocMutex(objLockPtr); + objLockPtr = NULL; + + TclpFreeAllocMutex(listLockPtr); + listLockPtr = NULL; +} + +#else + +/* + *---------------------------------------------------------------------- + * + * TclFinalizeThreadAlloc -- + * + * This procedure is used to destroy all private resources used in + * this file. + * + * Results: + * None. + * + * Side effects: + * None. + * + *---------------------------------------------------------------------- + */ + +void +TclFinalizeThreadAlloc() +{ + Tcl_Panic("TclFinalizeThreadAlloc called when threaded memory allocator not in use."); +} + #endif /* TCL_THREADS */ |