diff options
author | andreas_kupries <akupries@shaw.ca> | 2002-11-26 21:13:51 (GMT) |
---|---|---|
committer | andreas_kupries <akupries@shaw.ca> | 2002-11-26 21:13:51 (GMT) |
commit | 78847c8fca91c2dc6038f0ed87764f60dec3d9c8 (patch) | |
tree | fc5412b1d2d39349ed1d533b4d38807faa3c3b40 | |
parent | 89ac4498c816b1ec6d113bbda6c8aecc4764ffbf (diff) | |
download | tcl-78847c8fca91c2dc6038f0ed87764f60dec3d9c8.zip tcl-78847c8fca91c2dc6038f0ed87764f60dec3d9c8.tar.gz tcl-78847c8fca91c2dc6038f0ed87764f60dec3d9c8.tar.bz2 |
* tclBasic.c (CloneVariable): The initialization of the refCount
for the cloned variable assumed that all variables are namespace
variables. This is not true. Globals are not marked as in a
namespace. This caused the system to skip freeing all global
variables in a cloned interpreter. Changed to explicitly check
the variable if it is namespace'd.
-rw-r--r-- | ChangeLog | 9 | ||||
-rw-r--r-- | generic/tclBasic.c | 7 | ||||
-rw-r--r-- | tests/__clone.test | 3 |
3 files changed, 16 insertions, 3 deletions
@@ -1,3 +1,12 @@ +2002-11-26 Andreas Kupries <andreask@activestate.com> + + * tclBasic.c (CloneVariable): The initialization of the refCount + for the cloned variable assumed that all variables are namespace + variables. This is not true. Globals are not marked as in a + namespace. This caused the system to skip freeing all global + variables in a cloned interpreter. Changed to explicitly check + the variable if it is namespace'd. + 2002-11-26 Jeff Hobbs <jeffh@ActiveState.com> * tests/__clone.test: rename to allow it to be lexically first. diff --git a/generic/tclBasic.c b/generic/tclBasic.c index 00bfb15..cf7736a 100644 --- a/generic/tclBasic.c +++ b/generic/tclBasic.c @@ -12,7 +12,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclBasic.c,v 1.27.6.5 2002/11/26 19:48:49 andreas_kupries Exp $ + * RCS: @(#) $Id: tclBasic.c,v 1.27.6.6 2002/11/26 21:13:52 andreas_kupries Exp $ */ #include <assert.h> #include "tclInt.h" @@ -4291,10 +4291,13 @@ CloneVariable (interp, ns, varSrcPtr, varName, fixup) varNew->nsPtr = ns; varNew->tracePtr = NULL; /* Traces are not cloned */ varNew->searchPtr = NULL; - varNew->refCount = 1; /* Namespace variable */ + varNew->refCount = 0; /* Basic reference count */ varNew->name = NULL; /* Variable contained in hashtable of namespace. */ varNew->flags = varSrcPtr->flags; + if (varNew->flags & VAR_NAMESPACE_VAR) { + varNew->refCount++; + } if (varSrcPtr->flags & VAR_SCALAR) { /* * We share the object used as the contents of the scalar diff --git a/tests/__clone.test b/tests/__clone.test index af491c7..f5ee393 100644 --- a/tests/__clone.test +++ b/tests/__clone.test @@ -12,7 +12,7 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # -# RCS: @(#) $Id: __clone.test,v 1.1.2.1 2002/11/26 20:14:50 hobbs Exp $ +# RCS: @(#) $Id: __clone.test,v 1.1.2.2 2002/11/26 21:13:53 andreas_kupries Exp $ # allow the process to exit without calling the system exit, # to improve finalization cleanup @@ -28,6 +28,7 @@ if {[lsearch [namespace children] ::tcltest] == -1} { namespace import -force ::tcltest::* } +set ::___________________test 0 proc foo {} { # Have a compiled local variable. |