summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiguel Sofer <miguel.sofer@gmail.com>2005-04-11 00:40:27 (GMT)
committerMiguel Sofer <miguel.sofer@gmail.com>2005-04-11 00:40:27 (GMT)
commitf972ba16f4285b93f304d0fd094b21290346e9d8 (patch)
treed2a99f764a9f36c25bfbc6957800fc170c55c68d
parent68200e8ebce951cad13ba1cf0952f37879741071 (diff)
downloadtcl-f972ba16f4285b93f304d0fd094b21290346e9d8.zip
tcl-f972ba16f4285b93f304d0fd094b21290346e9d8.tar.gz
tcl-f972ba16f4285b93f304d0fd094b21290346e9d8.tar.bz2
* generic/tclCompCmds.c:
* generic/tclCompile.c: * generic/tclExecute.c: * generic/tclInt.h: * generic/tclProc.c: * generic/tclVar.c: part 2 of variable reform. Removed the flags VAR_SCALAR and VAR_UNDEFINED. * generic/tclExecute.c: missing semicolons under TCL_COMPILE_DEBUG * generic/tclInt.h: missing macros TclAllocObjsStorage and TclFreeObjStorage, not needed under MEM_DEBUG for Tcl_Objs but required for the new Var allocation model. Thanks dgp!
-rw-r--r--ChangeLog18
-rw-r--r--generic/tclBasic.c3
-rw-r--r--generic/tclCompCmds.c12
-rw-r--r--generic/tclCompile.c16
-rw-r--r--generic/tclExecute.c12
-rw-r--r--generic/tclInt.h77
-rw-r--r--generic/tclProc.c13
-rw-r--r--generic/tclVar.c25
8 files changed, 98 insertions, 78 deletions
diff --git a/ChangeLog b/ChangeLog
index 46bed63..1a8d12e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,23 @@
2005-04-10 Miguel Sofer <msofer@users.sf.net>
+ * generic/tclCompCmds.c:
+ * generic/tclCompile.c:
+ * generic/tclExecute.c:
+ * generic/tclInt.h:
+ * generic/tclProc.c:
+ * generic/tclVar.c: part 2 of variable reform. Removed the flags
+ VAR_SCALAR and VAR_UNDEFINED.
+
+
+ * generic/tclExecute.c: missing semicolons under TCL_COMPILE_DEBUG
+ * generic/tclInt.h: missing macros TclAllocObjsStorage and
+ TclFreeObjStorage, not needed under MEM_DEBUG for Tcl_Objs but
+ required for the new Var allocation model.
+ Thanks dgp!
+
+ *** FROM HEAD ***
+ * generic/tclBasic.c (TclObjInvoke): Plug memory leak. [Bug 1180368]
+
* generic/tcl.h (comments):
* generic/tclCmdIL.c:
* generic/tclCompile.c:
diff --git a/generic/tclBasic.c b/generic/tclBasic.c
index 2386456..df59104 100644
--- a/generic/tclBasic.c
+++ b/generic/tclBasic.c
@@ -13,7 +13,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.141.2.1 2005/04/02 13:36:05 msofer Exp $
+ * RCS: @(#) $Id: tclBasic.c,v 1.141.2.2 2005/04/11 00:40:29 msofer Exp $
*/
#include "tclInt.h"
@@ -4310,6 +4310,7 @@ TclObjInvoke(interp, objc, objv, flags)
CONST char* cmdString = Tcl_GetStringFromObj(command, &length);
Tcl_LogCommandInfo(interp, cmdString, cmdString, length);
+ Tcl_DecrRefCount(command);
iPtr->flags &= ~ERR_ALREADY_LOGGED;
}
return result;
diff --git a/generic/tclCompCmds.c b/generic/tclCompCmds.c
index 71932bd..30cba91 100644
--- a/generic/tclCompCmds.c
+++ b/generic/tclCompCmds.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: tclCompCmds.c,v 1.59.4.13 2005/03/28 22:21:25 msofer Exp $
+ * RCS: @(#) $Id: tclCompCmds.c,v 1.59.4.14 2005/04/11 00:40:29 msofer Exp $
*/
#include "tclInt.h"
@@ -197,7 +197,7 @@ TclCompileCatchCmd(interp, parsePtr, envPtr)
}
localIndex = TclFindCompiledLocal(nameTokenPtr[1].start,
nameTokenPtr[1].size, /*create*/ 1,
- /*flags*/ VAR_SCALAR, envPtr->procPtr);
+ /*flags*/ 0, envPtr->procPtr);
} else {
return TCL_OUT_LINE_COMPILE;
}
@@ -627,13 +627,13 @@ TclCompileForeachCmd(interp, parsePtr, envPtr)
firstValueTemp = -1;
for (loopIndex = 0; loopIndex < numLists; loopIndex++) {
tempVar = TclFindCompiledLocal(NULL, /*nameChars*/ 0,
- /*create*/ 1, /*flags*/ VAR_SCALAR, procPtr);
+ /*create*/ 1, /*flags*/ 0, procPtr);
if (loopIndex == 0) {
firstValueTemp = tempVar;
}
}
loopCtTemp = TclFindCompiledLocal(NULL, /*nameChars*/ 0,
- /*create*/ 1, /*flags*/ VAR_SCALAR, procPtr);
+ /*create*/ 1, /*flags*/ 0, procPtr);
/*
* Create and initialize the ForeachInfo and ForeachVarList data
@@ -656,7 +656,7 @@ TclCompileForeachCmd(interp, parsePtr, envPtr)
CONST char *varName = varvList[loopIndex][j];
int nameChars = strlen(varName);
varListPtr->varIndexes[j] = TclFindCompiledLocal(varName,
- nameChars, /*create*/ 1, /*flags*/ VAR_SCALAR, procPtr);
+ nameChars, /*create*/ 1, /*flags*/ 0, procPtr);
}
infoPtr->varLists[loopIndex] = varListPtr;
}
@@ -3098,7 +3098,7 @@ PushVarName(interp, varTokenPtr, envPtr, flags, localIndexPtr,
if ((envPtr->procPtr != NULL) && !hasNsQualifiers) {
localIndex = TclFindCompiledLocal(name, nameChars,
/*create*/ (flags & TCL_CREATE_VAR),
- /*flags*/ ((elName==NULL)? VAR_SCALAR : VAR_ARRAY),
+ /*flags*/ ((elName==NULL)? 0 : VAR_ARRAY),
envPtr->procPtr);
if (localIndex >= HPUINT_MAX) {
/* we'll push the name */
diff --git a/generic/tclCompile.c b/generic/tclCompile.c
index 0ae3e1c..3ff91b0 100644
--- a/generic/tclCompile.c
+++ b/generic/tclCompile.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: tclCompile.c,v 1.81.2.19 2005/04/10 18:13:47 msofer Exp $
+ * RCS: @(#) $Id: tclCompile.c,v 1.81.2.20 2005/04/11 00:40:29 msofer Exp $
*/
#include "tclInt.h"
@@ -1726,8 +1726,8 @@ TclFindCompiledLocal(name, nameBytes, create, flags, procPtr)
int create; /* If 1, allocate a local frame entry for
* the variable if it is new. */
int flags; /* Flag bits for the compiled local if
- * created. Only VAR_SCALAR, VAR_ARRAY, and
- * VAR_LINK make sense. */
+ * created. Only VAR_ARRAY, and VAR_LINK make
+ * sense. */
register Proc *procPtr; /* Points to structure describing procedure
* containing the variable reference. */
{
@@ -1773,7 +1773,7 @@ TclFindCompiledLocal(name, nameBytes, create, flags, procPtr)
localPtr->nextPtr = NULL;
localPtr->nameLength = nameBytes;
localPtr->frameIndex = localVar;
- localPtr->flags = flags | VAR_UNDEFINED;
+ localPtr->flags = flags;
if (name == NULL) {
localPtr->flags |= VAR_TEMPORARY;
}
@@ -2715,10 +2715,10 @@ TclPrintByteCodeObj(interp, objPtr)
if (numCompiledLocals > 0) {
CompiledLocal *localPtr = procPtr->firstLocalPtr;
for (i = 0; i < numCompiledLocals; i++) {
- fprintf(stdout, " slot %d%s%s%s%s%s%s", i,
- ((localPtr->flags & VAR_SCALAR)? ", scalar" : ""),
- ((localPtr->flags & VAR_ARRAY)? ", array" : ""),
- ((localPtr->flags & VAR_LINK)? ", link" : ""),
+ fprintf(stdout, " slot %d%s%s%s%s", i,
+ ((localPtr->flags & VAR_ARRAY)? ", array" :
+ ((localPtr->flags & VAR_LINK)? ", link" :
+ ", scalar")),
((localPtr->flags & VAR_ARGUMENT)? ", arg" : ""),
((localPtr->flags & VAR_TEMPORARY)? ", temp" : ""),
((localPtr->flags & VAR_RESOLVED)? ", resolved" : ""));
diff --git a/generic/tclExecute.c b/generic/tclExecute.c
index df2cd0c..092d4f3 100644
--- a/generic/tclExecute.c
+++ b/generic/tclExecute.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: tclExecute.c,v 1.171.2.21 2005/04/10 18:13:48 msofer Exp $
+ * RCS: @(#) $Id: tclExecute.c,v 1.171.2.22 2005/04/11 00:40:29 msofer Exp $
*/
#include "tclInt.h"
@@ -2050,7 +2050,6 @@ TclExecuteByteCode(interp, codePtr)
TclDecrRefCount(valuePtr);
} else {
TclSetVarScalar(varPtr);
- TclClearVarUndefined(varPtr);
}
varPtr->value.objPtr = objResultPtr;
if (pushRes) {
@@ -2139,7 +2138,6 @@ TclExecuteByteCode(interp, codePtr)
TclDecrRefCount(valuePtr);
} else {
TclSetVarScalar(varPtr);
- TclClearVarUndefined(varPtr);
}
varPtr->value.objPtr = objResultPtr;
Tcl_IncrRefCount(objResultPtr);
@@ -4067,8 +4065,8 @@ TclExecuteByteCode(interp, codePtr)
*/
if ((tPtr == &tclIntType) || (tPtr == &tclBooleanType)) {
i = valuePtr->internalRep.longValue;
- TclNewLongObj(objResultPtr, -i)
- TRACE_WITH_OBJ(("%ld => ", i), objResultPtr);
+ TclNewLongObj(objResultPtr, -i);
+ TRACE_WITH_OBJ(("%ld => ", i), objResultPtr);
} else if (tPtr == &tclWideIntType) {
TclGetWide(w,valuePtr);
TclNewWideIntObj(objResultPtr, -w);
@@ -4107,7 +4105,7 @@ TclExecuteByteCode(interp, codePtr)
i = (w != W0);
TRACE_WITH_OBJ((LLD" => ", w), objResultPtr);
} else {
- i = (valuePtr->internalRep.doubleValue != 0.0)
+ i = (valuePtr->internalRep.doubleValue != 0.0);
TRACE_WITH_OBJ(("%.6g => ", d), objResultPtr);
}
objResultPtr = ((inst == INST_LNOT)?
@@ -4400,7 +4398,6 @@ TclExecuteByteCode(interp, codePtr)
TclSetLongObj(oldValuePtr, -1);
}
TclSetVarScalar(iterVarPtr);
- TclClearVarUndefined(iterVarPtr);
TRACE(("%u => loop iter count temp %d\n",
(unsigned) opnd, iterTmpIndex));
@@ -4513,7 +4510,6 @@ TclExecuteByteCode(interp, codePtr)
TclDecrRefCount(value2Ptr);
} else {
TclSetVarScalar(varPtr);
- TclClearVarUndefined(varPtr);
}
varPtr->value.objPtr = valuePtr;
Tcl_IncrRefCount(valuePtr);
diff --git a/generic/tclInt.h b/generic/tclInt.h
index 7e15c08..ef8c4a7 100644
--- a/generic/tclInt.h
+++ b/generic/tclInt.h
@@ -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: tclInt.h,v 1.214.2.5 2005/04/10 18:13:50 msofer Exp $
+ * RCS: @(#) $Id: tclInt.h,v 1.214.2.6 2005/04/11 00:40:31 msofer Exp $
*/
#ifndef _TCLINT
@@ -487,17 +487,14 @@ typedef struct Var {
} Var;
/*
- * Flag bits for variables. The first three (VAR_SCALAR, VAR_ARRAY, and
- * VAR_LINK) are mutually exclusive and give the "type" of the variable.
- * VAR_UNDEFINED is independent of the variable's type.
+ * Flag bits for variables. The first two (VAR_ARRAY and VAR_LINK) are
+ * mutually exclusive and give the "type" of the variable; a scalar is
+ * neither an array nor a link.
+ * A variable with a NULL value is undefined: this means that the variable is
+ * in the process of being deleted. An undefined variable logically does not
+ * exist and survives only while it has a trace, or if it is a global variable
+ * currently being used by some procedure.
*
- * VAR_SCALAR - 1 means this is a scalar variable and not
- * an array or link. The "objPtr" field points
- * to the variable's value, a Tcl object.
- * VAR_ARRAY - 1 means this is an array variable rather
- * than a scalar variable or link. The
- * "tablePtr" field points to the array's
- * hashtable for its elements.
* VAR_LINK - 1 means this Var structure contains a
* pointer to another Var structure that
* either has the real value or is itself
@@ -505,12 +502,6 @@ typedef struct Var {
* this come about through "upvar" and "global"
* commands, or through references to variables
* in enclosing namespaces.
- * VAR_UNDEFINED - 1 means that the variable is in the process
- * of being deleted. An undefined variable
- * logically does not exist and survives only
- * while it has a trace, or if it is a global
- * variable currently being used by some
- * procedure.
* VAR_IN_HASHTABLE - 1 means this variable is in a hashtable and
* the Var structure is malloced. 0 if it is
* a local variable that was assigned a slot
@@ -544,12 +535,28 @@ typedef struct Var {
* name.
* VAR_RESOLVED - 1 if name resolution has been done for this
* variable.
+ *
+ * The following additional flags are used to speed up variable access by
+ * the bytecode engine. The information contained is already present in the
+ * other flag values and/or the fields of the Var structure. There is special
+ * code to maintain these flag values in synch with the rest.
+ *
+ * VAR_DIRECT_READABLE 1 means that TEBC can read this variable
+ * directly:
+ * - VAR_SCALAR is set
+ * - VAR_UNDEFINED is not set
+ * - tracePtr is NULL.
+ * VAR_DIRECT_WRITABLE 1 means that TEBC can write this variable
+ * directly:
+ * - one of {VAR_SCALAR,VAR_UNDEFINED} is set
+ * - tracePtr is NULL
+ * - VAR_IN_HASHTABLE is not set, or else hPtr
+ * is not NULL.
*/
-#define VAR_SCALAR 0x1
#define VAR_ARRAY 0x2
#define VAR_LINK 0x4
-#define VAR_UNDEFINED 0x8
+
#define VAR_IN_HASHTABLE 0x10
#define VAR_TRACE_ACTIVE 0x20
#define VAR_ARRAY_ELEMENT 0x40
@@ -560,6 +567,9 @@ typedef struct Var {
#define VAR_RESOLVED 0x400
#define VAR_IS_ARGS 0x800
+#define VAR_DIRECT_READABLE 0x1000
+#define VAR_DIRECT_WRITABLE 0x2000
+
/*
* Macros to ensure that various flag bits are set properly for variables.
* The ANSI C "prototypes" for these macros are:
@@ -573,22 +583,20 @@ typedef struct Var {
*/
#define TclSetVarScalar(varPtr) \
- (varPtr)->flags = ((varPtr)->flags & ~(VAR_ARRAY|VAR_LINK)) | VAR_SCALAR
+ (varPtr)->flags = ((varPtr)->flags & ~(VAR_ARRAY|VAR_LINK))
#define TclSetVarArray(varPtr) \
- (varPtr)->flags = ((varPtr)->flags & ~(VAR_SCALAR|VAR_LINK)) | VAR_ARRAY
+ (varPtr)->flags = ((varPtr)->flags & ~VAR_LINK) | VAR_ARRAY
#define TclSetVarLink(varPtr) \
- (varPtr)->flags = ((varPtr)->flags & ~(VAR_SCALAR|VAR_ARRAY)) | VAR_LINK
+ (varPtr)->flags = ((varPtr)->flags & ~VAR_ARRAY) | VAR_LINK
#define TclSetVarArrayElement(varPtr) \
(varPtr)->flags = ((varPtr)->flags & ~VAR_ARRAY) | VAR_ARRAY_ELEMENT
#define TclSetVarUndefined(varPtr) \
- (varPtr)->flags |= VAR_UNDEFINED
-
-#define TclClearVarUndefined(varPtr) \
- (varPtr)->flags &= ~VAR_UNDEFINED
+ (varPtr)->value.objPtr = NULL; \
+ TclSetVarScalar(varPtr)
#define TclSetVarTraceActive(varPtr) \
(varPtr)->flags |= VAR_TRACE_ACTIVE
@@ -617,7 +625,7 @@ typedef struct Var {
*/
#define TclIsVarScalar(varPtr) \
- ((varPtr)->flags & VAR_SCALAR)
+ !((varPtr)->flags & (VAR_ARRAY|VAR_LINK))
#define TclIsVarLink(varPtr) \
((varPtr)->flags & VAR_LINK)
@@ -626,7 +634,7 @@ typedef struct Var {
((varPtr)->flags & VAR_ARRAY)
#define TclIsVarUndefined(varPtr) \
- ((varPtr)->flags & VAR_UNDEFINED)
+ ((varPtr)->value.objPtr == NULL)
#define TclIsVarArrayElement(varPtr) \
((varPtr)->flags & VAR_ARRAY_ELEMENT)
@@ -2580,6 +2588,19 @@ MODULE_SCOPE void TclDbInitNewObj _ANSI_ARGS_((Tcl_Obj *objPtr));
# define TclNewListObjDirect(objc, objv) \
TclDbNewListObjDirect(objc, objv, __FILE__, __LINE__)
+#define TclAllocObjStorage(objPtr) \
+ TclNewObj(objPtr)
+
+#define TclFreeObjStorage(anyPtr) \
+ {\
+ Tcl_Obj *objPtr = (Tcl_Obj *) (anyPtr);\
+ objPtr->refCount = 1;\
+ objPtr->bytes = tclEmptyStringRep;\
+ objPtr->length = 0;\
+ objPtr->typePtr = NULL;\
+ TclDecrRefCount(objPtr);\
+ }
+
#undef USE_THREAD_ALLOC
#endif /* TCL_MEM_DEBUG */
diff --git a/generic/tclProc.c b/generic/tclProc.c
index 32a0551..4ae7a19 100644
--- a/generic/tclProc.c
+++ b/generic/tclProc.c
@@ -10,7 +10,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclProc.c,v 1.73.2.2 2005/04/10 18:13:51 msofer Exp $
+ * RCS: @(#) $Id: tclProc.c,v 1.73.2.3 2005/04/11 00:40:32 msofer Exp $
*/
#include "tclInt.h"
@@ -412,16 +412,15 @@ TclCreateProc(interp, nsPtr, procName, argsPtr, bodyPtr, procPtrPtr)
if (precompiled) {
/*
* Compare the parsed argument with the stored one.
- * For the flags, we and out VAR_UNDEFINED to support bridging
- * precompiled <= 8.3 code in 8.4 where this is now used as an
- * optimization indicator. Yes, this is a hack. -- hobbs
+ *
+ * NOTE: code precompiled under older versions of Tcl will not
+ * work properly.
*/
if ((localPtr->nameLength != nameLength)
|| (strcmp(localPtr->name, fieldValues[0]))
|| (localPtr->frameIndex != i)
- || ((localPtr->flags & ~VAR_UNDEFINED)
- != (VAR_SCALAR | VAR_ARGUMENT))
+ || (localPtr->flags != VAR_ARGUMENT)
|| (localPtr->defValuePtr == NULL && fieldCount == 2)
|| (localPtr->defValuePtr != NULL && fieldCount != 2)) {
char buf[40 + TCL_INTEGER_SPACE];
@@ -477,7 +476,7 @@ TclCreateProc(interp, nsPtr, procName, argsPtr, bodyPtr, procPtrPtr)
localPtr->nextPtr = NULL;
localPtr->nameLength = nameLength;
localPtr->frameIndex = i;
- localPtr->flags = VAR_SCALAR | VAR_ARGUMENT;
+ localPtr->flags = VAR_ARGUMENT;
localPtr->resolveInfo = NULL;
if (fieldCount == 2) {
diff --git a/generic/tclVar.c b/generic/tclVar.c
index b0348ff..0fc07be 100644
--- a/generic/tclVar.c
+++ b/generic/tclVar.c
@@ -15,7 +15,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclVar.c,v 1.101.2.3 2005/04/10 18:13:51 msofer Exp $
+ * RCS: @(#) $Id: tclVar.c,v 1.101.2.4 2005/04/11 00:40:32 msofer Exp $
*/
#include "tclInt.h"
@@ -943,7 +943,6 @@ TclLookupArrayElement(interp, arrayName, elName, flags, msg, createArray, create
}
TclSetVarArray(arrayPtr);
- TclClearVarUndefined(arrayPtr);
arrayPtr->value.tablePtr =
(Tcl_HashTable *) ckalloc(sizeof(Tcl_HashTable));
Tcl_InitHashTable(arrayPtr->value.tablePtr, TCL_STRING_KEYS);
@@ -1612,10 +1611,10 @@ TclPtrSetVar(interp, varPtr, arrayPtr, part1, part2, newValuePtr, flags)
* "copy on write".
*/
+ oldValuePtr = varPtr->value.objPtr;
if (flags & TCL_LIST_ELEMENT && !(flags & TCL_APPEND_VALUE)) {
TclSetVarUndefined(varPtr);
}
- oldValuePtr = varPtr->value.objPtr;
if (flags & (TCL_APPEND_VALUE|TCL_LIST_ELEMENT)) {
if (TclIsVarUndefined(varPtr) && (oldValuePtr != NULL)) {
TclDecrRefCount(oldValuePtr); /* discard old value */
@@ -1669,10 +1668,6 @@ TclPtrSetVar(interp, varPtr, arrayPtr, part1, part2, newValuePtr, flags)
}
}
TclSetVarScalar(varPtr);
- TclClearVarUndefined(varPtr);
- if (arrayPtr != NULL) {
- TclClearVarUndefined(arrayPtr);
- }
/*
* Invoke any write traces for the variable.
@@ -2181,8 +2176,6 @@ TclObjUnsetVar2(interp, part1Ptr, part2, flags)
dummyVar = *varPtr;
TclSetVarUndefined(varPtr);
- TclSetVarScalar(varPtr);
- varPtr->value.objPtr = NULL; /* dummyVar points to any value object */
varPtr->tracePtr = NULL;
varPtr->searchPtr = NULL;
@@ -3245,7 +3238,6 @@ TclArraySet(interp, arrayNameObj, arrayElemObj)
}
}
TclSetVarArray(varPtr);
- TclClearVarUndefined(varPtr);
varPtr->value.tablePtr =
(Tcl_HashTable *) ckalloc(sizeof(Tcl_HashTable));
Tcl_InitHashTable(varPtr->value.tablePtr, TCL_STRING_KEYS);
@@ -3421,7 +3413,6 @@ ObjMakeUpvar(interp, framePtr, otherP1Ptr, otherP2, otherFlags, myName, myFlags,
}
}
TclSetVarLink(varPtr);
- TclClearVarUndefined(varPtr);
varPtr->value.linkPtr = otherPtr;
otherPtr->refCount++;
return TCL_OK;
@@ -3895,7 +3886,7 @@ NewVar()
TclAllocObjStorage(objPtr);
varPtr = (Var *) objPtr;
- varPtr->flags = (VAR_SCALAR | VAR_UNDEFINED | VAR_IN_HASHTABLE);
+ varPtr->flags = VAR_IN_HASHTABLE;
varPtr->value.objPtr = NULL;
varPtr->id.name = NULL;
varPtr->refCount = 0;
@@ -4192,17 +4183,14 @@ TclDeleteVars(iPtr, tablePtr)
if (TclIsVarArray(varPtr)) {
DeleteArray(iPtr, Tcl_GetHashKey(tablePtr, hPtr), varPtr,
flags);
- varPtr->value.tablePtr = NULL;
}
if (TclIsVarScalar(varPtr) && (varPtr->value.objPtr != NULL)) {
objPtr = varPtr->value.objPtr;
TclDecrRefCount(objPtr);
- varPtr->value.objPtr = NULL;
}
+ TclSetVarUndefined(varPtr);
varPtr->id.hPtr = NULL;
varPtr->tracePtr = NULL;
- TclSetVarUndefined(varPtr);
- TclSetVarScalar(varPtr);
/*
* If the variable was a namespace variable, decrement its
@@ -4325,12 +4313,10 @@ TclDeleteCompiledLocalVars(iPtr, framePtr)
}
if (TclIsVarScalar(varPtr) && (varPtr->value.objPtr != NULL)) {
TclDecrRefCount(varPtr->value.objPtr);
- varPtr->value.objPtr = NULL;
}
+ TclSetVarUndefined(varPtr);
varPtr->id.hPtr = NULL;
varPtr->tracePtr = NULL;
- TclSetVarUndefined(varPtr);
- TclSetVarScalar(varPtr);
varPtr++;
}
}
@@ -4403,7 +4389,6 @@ DeleteArray(iPtr, arrayName, varPtr, flags)
}
}
TclSetVarUndefined(elPtr);
- TclSetVarScalar(elPtr);
/*
* Even though array elements are not supposed to be namespace