diff options
author | dgp <dgp@users.sourceforge.net> | 2014-04-23 18:25:27 (GMT) |
---|---|---|
committer | dgp <dgp@users.sourceforge.net> | 2014-04-23 18:25:27 (GMT) |
commit | fe4debabde73db9d51c655f61d19bc8d23956668 (patch) | |
tree | 8b77f40dadcc9f07791387401ab293f6213d6fff /generic | |
parent | 190e2f09e8fa5bc975ba496a5544b4dd853378f0 (diff) | |
parent | f231f10b58b9f58583b664655b513d3f3ee0c382 (diff) | |
download | tcl-fe4debabde73db9d51c655f61d19bc8d23956668.zip tcl-fe4debabde73db9d51c655f61d19bc8d23956668.tar.gz tcl-fe4debabde73db9d51c655f61d19bc8d23956668.tar.bz2 |
[3493120] Plug memory leak in thread exit.
Diffstat (limited to 'generic')
-rw-r--r-- | generic/tclInt.h | 1 | ||||
-rw-r--r-- | generic/tclThread.c | 8 | ||||
-rw-r--r-- | generic/tclThreadAlloc.c | 27 |
3 files changed, 34 insertions, 2 deletions
diff --git a/generic/tclInt.h b/generic/tclInt.h index 1348340..00b246b 100644 --- a/generic/tclInt.h +++ b/generic/tclInt.h @@ -2550,6 +2550,7 @@ MODULE_SCOPE void TclFinalizeObjects(void); MODULE_SCOPE void TclFinalizePreserve(void); MODULE_SCOPE void TclFinalizeSynchronization(void); MODULE_SCOPE void TclFinalizeThreadAlloc(void); +MODULE_SCOPE void TclFinalizeThreadAllocThread(void); MODULE_SCOPE void TclFinalizeThreadData(void); MODULE_SCOPE void TclFinalizeThreadObjects(void); MODULE_SCOPE double TclFloor(mp_int *a); diff --git a/generic/tclThread.c b/generic/tclThread.c index 8384107..d6b5bcb 100644 --- a/generic/tclThread.c +++ b/generic/tclThread.c @@ -338,8 +338,9 @@ Tcl_ConditionFinalize( * * TclFinalizeThreadData -- * - * This function cleans up the thread-local storage. This is called once - * for each thread. + * This function cleans up the thread-local storage. Secondary, it cleans + * thread alloc cache. + * This is called once for each thread before thread exits. * * Results: * None. @@ -354,6 +355,9 @@ void TclFinalizeThreadData(void) { TclpFinalizeThreadDataThread(); +#if defined(TCL_THREADS) && defined(USE_THREAD_ALLOC) + TclFinalizeThreadAllocThread(); +#endif } /* diff --git a/generic/tclThreadAlloc.c b/generic/tclThreadAlloc.c index 2e74fa7..106e908 100644 --- a/generic/tclThreadAlloc.c +++ b/generic/tclThreadAlloc.c @@ -1012,6 +1012,33 @@ TclFinalizeThreadAlloc(void) TclpFreeAllocCache(NULL); } +/* + *---------------------------------------------------------------------- + * + * TclFinalizeThreadAllocThread -- + * + * This procedure is used to destroy single thread private resources used + * in this file. + * Called in TclpFinalizeThreadData when a thread exits (Tcl_FinalizeThread). + * + * Results: + * None. + * + * Side effects: + * None. + * + *---------------------------------------------------------------------- + */ + +void +TclFinalizeThreadAllocThread(void) +{ + Cache *cachePtr = TclpGetAllocCache(); + if (cachePtr != NULL) { + TclpFreeAllocCache(cachePtr); + } +} + #else /* !(TCL_THREADS && USE_THREAD_ALLOC) */ /* *---------------------------------------------------------------------- |