diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2016-04-01 12:00:36 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2016-04-01 12:00:36 (GMT) |
commit | eba6ef86a9f558df5aefa64822b05a678517740d (patch) | |
tree | bb5296be8b28a43682af2305936d3c551424d64d /win/tclWinThrd.c | |
parent | 890c05b7130f318175535dc345dc530c9c52dd48 (diff) | |
parent | ffcf42745c6b45037104720cdd15d5d7003fdb63 (diff) | |
download | tcl-eba6ef86a9f558df5aefa64822b05a678517740d.zip tcl-eba6ef86a9f558df5aefa64822b05a678517740d.tar.gz tcl-eba6ef86a9f558df5aefa64822b05a678517740d.tar.bz2 |
merge trunk
Diffstat (limited to 'win/tclWinThrd.c')
-rw-r--r-- | win/tclWinThrd.c | 33 |
1 files changed, 15 insertions, 18 deletions
diff --git a/win/tclWinThrd.c b/win/tclWinThrd.c index 023122f..4b4f870 100644 --- a/win/tclWinThrd.c +++ b/win/tclWinThrd.c @@ -117,7 +117,6 @@ typedef struct { */ #ifdef USE_THREAD_ALLOC -static int once; static DWORD tlsKey; typedef struct { @@ -966,24 +965,24 @@ TclpFreeAllocMutex( free(lockPtr); } +void +TclpInitAllocCache(void) +{ + /* + * We need to make sure that TclpFreeAllocCache is called on each + * thread that calls this, but only on threads that call this. + */ + + tlsKey = TlsAlloc(); + if (tlsKey == TLS_OUT_OF_INDEXES) { + Tcl_Panic("could not allocate thread local storage"); + } +} + void * TclpGetAllocCache(void) { void *result; - - if (!once) { - /* - * We need to make sure that TclpFreeAllocCache is called on each - * thread that calls this, but only on threads that call this. - */ - - tlsKey = TlsAlloc(); - once = 1; - if (tlsKey == TLS_OUT_OF_INDEXES) { - Tcl_Panic("could not allocate thread local storage"); - } - } - result = TlsGetValue(tlsKey); if ((result == NULL) && (GetLastError() != NO_ERROR)) { Tcl_Panic("TlsGetValue failed from TclpGetAllocCache"); @@ -1019,7 +1018,7 @@ TclpFreeAllocCache( if (!success) { Tcl_Panic("TlsSetValue failed from TclpFreeAllocCache"); } - } else if (once) { + } else { /* * Called by us in TclFinalizeThreadAlloc() during the library * finalization initiated from Tcl_Finalize() @@ -1029,9 +1028,7 @@ TclpFreeAllocCache( if (!success) { Tcl_Panic("TlsFree failed from TclpFreeAllocCache"); } - once = 0; /* reset for next time. */ } - } #endif /* USE_THREAD_ALLOC */ |