summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authorpooryorick <com.digitalsmarties@pooryorick.com>2021-05-15 18:42:40 (GMT)
committerpooryorick <com.digitalsmarties@pooryorick.com>2021-05-15 18:42:40 (GMT)
commit1134511a980250dfb27153be57b4e64e8455cdfe (patch)
tree3cebf719433c4728b84db361d6af01781fd019dc /generic
parent0f818acbb72a2b4792acb1d82f051507c76e59a2 (diff)
downloadtcl-1134511a980250dfb27153be57b4e64e8455cdfe.zip
tcl-1134511a980250dfb27153be57b4e64e8455cdfe.tar.gz
tcl-1134511a980250dfb27153be57b4e64e8455cdfe.tar.bz2
When deleting an interp, delete associated data after running the corresponding
Tcl_InterpDeleteProc instead of before to allow the Tcl_InterpDeleteProc to make use of the data. In TcltestObj.c/VarPtrDeleteProc, remove call to Tcl_DeleteAssocData that is redundant and cylic.
Diffstat (limited to 'generic')
-rw-r--r--generic/tclBasic.c14
-rw-r--r--generic/tclTestObj.c1
2 files changed, 7 insertions, 8 deletions
diff --git a/generic/tclBasic.c b/generic/tclBasic.c
index 5ca70d4..2d10812 100644
--- a/generic/tclBasic.c
+++ b/generic/tclBasic.c
@@ -1826,28 +1826,28 @@ DeleteInterpProc(
ckfree(hTablePtr);
}
- /*
- * Invoke deletion callbacks; note that a callback can create new
- * callbacks, so we iterate.
- */
- while (iPtr->assocData != NULL) {
+ if (iPtr->assocData != NULL) {
AssocData *dPtr;
hTablePtr = iPtr->assocData;
- iPtr->assocData = NULL;
+ /*
+ * Invoke deletion callbacks; note that a callback can create new
+ * callbacks, so we iterate.
+ */
for (hPtr = Tcl_FirstHashEntry(hTablePtr, &search);
hPtr != NULL;
hPtr = Tcl_FirstHashEntry(hTablePtr, &search)) {
dPtr = (AssocData *)Tcl_GetHashValue(hPtr);
- Tcl_DeleteHashEntry(hPtr);
if (dPtr->proc != NULL) {
dPtr->proc(dPtr->clientData, interp);
}
+ Tcl_DeleteHashEntry(hPtr);
ckfree(dPtr);
}
Tcl_DeleteHashTable(hTablePtr);
ckfree(hTablePtr);
+ iPtr->assocData = NULL;
}
/*
diff --git a/generic/tclTestObj.c b/generic/tclTestObj.c
index 17546a4..4e7cec9 100644
--- a/generic/tclTestObj.c
+++ b/generic/tclTestObj.c
@@ -61,7 +61,6 @@ static void VarPtrDeleteProc(void *clientData, Tcl_Interp *interp)
for (i = 0; i < NUMBER_OF_OBJECT_VARS; i++) {
if (varPtr[i]) Tcl_DecrRefCount(varPtr[i]);
}
- Tcl_DeleteAssocData(interp, VARPTR_KEY);
ckfree(varPtr);
}