diff options
author | hobbs <hobbs> | 2004-07-21 01:45:44 (GMT) |
---|---|---|
committer | hobbs <hobbs> | 2004-07-21 01:45:44 (GMT) |
commit | 4dcfe1cc24fd10bd3e184990a3b7f7c3042d6e03 (patch) | |
tree | a73f70550f592464825b855b97bcf3574735f983 /win | |
parent | b7baa5cf544d8865daa4745ad9616caabfedd664 (diff) | |
download | tcl-4dcfe1cc24fd10bd3e184990a3b7f7c3042d6e03.zip tcl-4dcfe1cc24fd10bd3e184990a3b7f7c3042d6e03.tar.gz tcl-4dcfe1cc24fd10bd3e184990a3b7f7c3042d6e03.tar.bz2 |
* generic/tclEvent.c: Correct threaded obj allocator to
* generic/tclInt.h: fully cleanup on exit and allow for
* generic/tclThreadAlloc.c: reinitialization. [Bug #736426]
* unix/tclUnixThrd.c: (mistachkin, kenny)
* win/tclWinThrd.c:
Diffstat (limited to 'win')
-rw-r--r-- | win/tclWinThrd.c | 35 |
1 files changed, 28 insertions, 7 deletions
diff --git a/win/tclWinThrd.c b/win/tclWinThrd.c index c968a53..e2f399f 100644 --- a/win/tclWinThrd.c +++ b/win/tclWinThrd.c @@ -9,7 +9,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclWinThrd.c,v 1.32 2004/07/19 19:19:07 vasiljevic Exp $ + * RCS: @(#) $Id: tclWinThrd.c,v 1.33 2004/07/21 01:45:45 hobbs Exp $ */ #include "tclWinInt.h" @@ -1040,17 +1040,20 @@ TclpFinalizeCondition(condPtr) * Additions by AOL for specialized thread memory allocator. */ #ifdef USE_THREAD_ALLOC +static int once; static DWORD key; +typedef struct allocMutex { + Tcl_Mutex tlock; + CRITICAL_SECTION wlock; +} allocMutex; + Tcl_Mutex * TclpNewAllocMutex(void) { - struct lock { - Tcl_Mutex tlock; - CRITICAL_SECTION wlock; - } *lockPtr; + struct allocMutex *lockPtr; - lockPtr = malloc(sizeof(struct lock)); + lockPtr = malloc(sizeof(struct allocMutex)); if (lockPtr == NULL) { Tcl_Panic("could not allocate lock"); } @@ -1059,10 +1062,19 @@ TclpNewAllocMutex(void) return &lockPtr->tlock; } +void +TclpFreeAllocMutex(mutex) + Tcl_Mutex *mutex; /* The alloc mutex to free. */ +{ + allocMutex* lockPtr = (allocMutex*) mutex; + if (!lockPtr) return; + DeleteCriticalSection(&lockPtr->wlock); + free(lockPtr); +} + void * TclpGetAllocCache(void) { - static int once = 0; VOID *result; if (!once) { @@ -1113,6 +1125,15 @@ TclWinFreeAllocCache(void) Tcl_Panic("TlsGetValue failed from TclWinFreeAllocCache!"); } } + + if (once) { + success = TlsFree(key); + if (!success) { + Tcl_Panic("TlsFree failed from TclWinFreeAllocCache!"); + } + + once = 0; /* reset for next time. */ + } } #endif /* USE_THREAD_ALLOC */ |