summaryrefslogtreecommitdiffstats
path: root/generic/tclVar.c
diff options
context:
space:
mode:
Diffstat (limited to 'generic/tclVar.c')
-rw-r--r--generic/tclVar.c49
1 files changed, 16 insertions, 33 deletions
diff --git a/generic/tclVar.c b/generic/tclVar.c
index 0b371ee..48e09f6 100644
--- a/generic/tclVar.c
+++ b/generic/tclVar.c
@@ -5032,44 +5032,27 @@ TclDeleteVars(
TclVarHashTable *tablePtr) /* Hash table containing variables to
* delete. */
{
+ Tcl_Interp *interp = (Tcl_Interp *) iPtr;
Tcl_HashSearch search;
register Var *varPtr;
+ int flags;
+ Namespace *currNsPtr = (Namespace *) TclGetCurrentNamespace(interp);
- for (varPtr = VarHashFirstVar(tablePtr, &search); varPtr != NULL;
- varPtr = VarHashFirstVar(tablePtr, &search)) {
- VarHashRefCount(varPtr)++;
-
- UnsetVarStruct(varPtr, NULL, iPtr, VarHashGetKey(varPtr),
- NULL, TCL_TRACE_UNSETS, -1);
-
- if (TclIsVarTraced(varPtr)) {
- Tcl_HashEntry *tPtr = Tcl_FindHashEntry(&iPtr->varTraces, varPtr);
- VarTrace *tracePtr = Tcl_GetHashValue(tPtr);
- ActiveVarTrace *activePtr;
-
- while (tracePtr) {
- VarTrace *prevPtr = tracePtr;
-
- tracePtr = tracePtr->nextPtr;
- prevPtr->nextPtr = NULL;
- Tcl_EventuallyFree(prevPtr, TCL_DYNAMIC);
- }
- Tcl_DeleteHashEntry(tPtr);
- varPtr->flags &= ~VAR_ALL_TRACES;
- for (activePtr = iPtr->activeVarTracePtr; activePtr != NULL;
- activePtr = activePtr->nextPtr) {
- if (activePtr->varPtr == varPtr) {
- activePtr->nextTracePtr = NULL;
- }
- }
- }
+ /*
+ * Determine what flags to pass to the trace callback functions.
+ */
- if (!TclIsVarUndefined(varPtr)) {
- UnsetVarStruct(varPtr, NULL, iPtr, VarHashGetKey(varPtr),
- NULL, TCL_TRACE_UNSETS, -1);
- }
+ flags = TCL_TRACE_UNSETS;
+ if (tablePtr == &iPtr->globalNsPtr->varTable) {
+ flags |= TCL_GLOBAL_ONLY;
+ } else if (tablePtr == &currNsPtr->varTable) {
+ flags |= TCL_NAMESPACE_ONLY;
+ }
- VarHashRefCount(varPtr)--;
+ for (varPtr = VarHashFirstVar(tablePtr, &search); varPtr != NULL;
+ varPtr = VarHashFirstVar(tablePtr, &search)) {
+ UnsetVarStruct(varPtr, NULL, iPtr, VarHashGetKey(varPtr), NULL, flags,
+ -1);
VarHashDeleteEntry(varPtr);
}
VarHashDeleteTable(tablePtr);