diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2017-12-21 13:26:56 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2017-12-21 13:26:56 (GMT) |
commit | 53795bd1990e95c19850746d2117171a40d7ceef (patch) | |
tree | f3f600f0c8409baeb7baa898d4c21e00e43698ff /generic/tclNamesp.c | |
parent | 5c4f8d88b5491e7656dedeab904b42b437b83e01 (diff) | |
parent | 5a190dd003f0caaee265f6664bd1bbee842a2d66 (diff) | |
download | tcl-53795bd1990e95c19850746d2117171a40d7ceef.zip tcl-53795bd1990e95c19850746d2117171a40d7ceef.tar.gz tcl-53795bd1990e95c19850746d2117171a40d7ceef.tar.bz2 |
merge core-8-branch
Diffstat (limited to 'generic/tclNamesp.c')
-rw-r--r-- | generic/tclNamesp.c | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/generic/tclNamesp.c b/generic/tclNamesp.c index d661856..f82d23d 100644 --- a/generic/tclNamesp.c +++ b/generic/tclNamesp.c @@ -32,7 +32,7 @@ */ typedef struct { - size_t numNsCreated; /* Count of the number of namespaces created + unsigned long numNsCreated; /* Count of the number of namespaces created * within the thread. This value is used as a * unique id for each namespace. Cannot be * per-interp because the nsId is used to @@ -402,7 +402,7 @@ Tcl_PopCallFrame( } if (framePtr->numCompiledLocals > 0) { TclDeleteCompiledLocalVars(iPtr, framePtr); - if (--framePtr->localCachePtr->refCount == 0) { + if (framePtr->localCachePtr->refCount-- <= 1) { TclFreeLocalCache(interp, framePtr->localCachePtr); } framePtr->localCachePtr = NULL; @@ -916,6 +916,11 @@ Tcl_DeleteNamespace( Command *cmdPtr; /* + * Ensure that this namespace doesn't get deallocated in the meantime. + */ + nsPtr->refCount++; + + /* * Give anyone interested - notably TclOO - a chance to use this namespace * normally despite the fact that the namespace is going to go. Allows the * calling of destructors. Will only be called once (unless re-established @@ -1047,16 +1052,7 @@ Tcl_DeleteNamespace( #endif Tcl_DeleteHashTable(&nsPtr->cmdTable); - /* - * If the reference count is 0, then discard the namespace. - * Otherwise, mark it as "dead" so that it can't be used. - */ - - if (nsPtr->refCount == 0) { - NamespaceFree(nsPtr); - } else { - nsPtr->flags |= NS_DEAD; - } + nsPtr ->flags |= NS_DEAD; } else { /* * Restore the ::errorInfo and ::errorCode traces. @@ -1073,6 +1069,7 @@ Tcl_DeleteNamespace( nsPtr->flags &= ~(NS_DYING|NS_KILLED); } } + TclNsDecrRefCount(nsPtr); } /* |