summaryrefslogtreecommitdiffstats
path: root/generic/tclEvent.c
diff options
context:
space:
mode:
authordavygrvy <davygrvy@pobox.com>2004-04-23 02:04:54 (GMT)
committerdavygrvy <davygrvy@pobox.com>2004-04-23 02:04:54 (GMT)
commite41ca99af6cc15d36aae35b5a7ef212f65f26dab (patch)
tree0f9b25a439687979f2af311a55333bf3c8ca66dc /generic/tclEvent.c
parent1f89d8146b999776f7affe00b2856dc17e580a6a (diff)
downloadtcl-e41ca99af6cc15d36aae35b5a7ef212f65f26dab.zip
tcl-e41ca99af6cc15d36aae35b5a7ef212f65f26dab.tar.gz
tcl-e41ca99af6cc15d36aae35b5a7ef212f65f26dab.tar.bz2
TclSetLibraryPath's use of caching the stringrep of the pathPtr object to
TclGetLibraryPath called from another thread was ineffective if the original's stringrep had been invalidated as what happens when it gets muted to a list.
Diffstat (limited to 'generic/tclEvent.c')
-rw-r--r--generic/tclEvent.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/generic/tclEvent.c b/generic/tclEvent.c
index f0cbf8b..32ec7f8 100644
--- a/generic/tclEvent.c
+++ b/generic/tclEvent.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: tclEvent.c,v 1.32 2004/04/06 22:25:50 dgp Exp $
+ * RCS: @(#) $Id: tclEvent.c,v 1.33 2004/04/23 02:04:54 davygrvy Exp $
*/
#include "tclInt.h"
@@ -107,8 +107,9 @@ static Tcl_ThreadDataKey dataKey;
/*
* Common string for the library path for sharing across threads.
+ * This is ckalloc'd and cleared in Tcl_Finalize.
*/
-char *tclLibraryPathStr;
+static char *tclLibraryPathStr = NULL;
/*
* Prototypes for procedures referenced only in this file:
@@ -656,6 +657,8 @@ TclSetLibraryPath(pathPtr)
* the new library path. */
{
ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey);
+ const char *toDupe;
+ int size;
if (pathPtr != NULL) {
Tcl_IncrRefCount(pathPtr);
@@ -669,7 +672,12 @@ TclSetLibraryPath(pathPtr)
* No mutex locking is needed here as up the stack we're within
* TclpInitLock().
*/
- tclLibraryPathStr = Tcl_GetStringFromObj(pathPtr, NULL);
+ if (tclLibraryPathStr != NULL) {
+ ckfree(tclLibraryPathStr);
+ }
+ toDupe = Tcl_GetStringFromObj(pathPtr, &size);
+ tclLibraryPathStr = ckalloc(size+1);
+ strcpy(tclLibraryPathStr, toDupe);
}
/*
@@ -905,6 +913,10 @@ Tcl_Finalize()
ckfree(tclDefaultEncodingDir);
tclDefaultEncodingDir = NULL;
}
+ if (tclLibraryPathStr != NULL) {
+ ckfree(tclLibraryPathStr);
+ tclLibraryPathStr = NULL;
+ }
Tcl_SetPanicProc(NULL);