aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--jim.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/jim.c b/jim.c
index ea70d35..4070206 100644
--- a/jim.c
+++ b/jim.c
@@ -2307,11 +2307,12 @@ static void JimSetStringBytes(Jim_Obj *objPtr, const char *str)
}
static void FreeDictSubstInternalRep(Jim_Interp *interp, Jim_Obj *objPtr);
+static void DupDictSubstInternalRep(Jim_Interp *interp, Jim_Obj *srcPtr, Jim_Obj *dupPtr);
static const Jim_ObjType dictSubstObjType = {
"dict-substitution",
FreeDictSubstInternalRep,
- NULL,
+ DupDictSubstInternalRep,
NULL,
JIM_TYPE_NONE,
};
@@ -4875,6 +4876,15 @@ void FreeDictSubstInternalRep(Jim_Interp *interp, Jim_Obj *objPtr)
Jim_DecrRefCount(interp, objPtr->internalRep.dictSubstValue.indexObjPtr);
}
+static void DupDictSubstInternalRep(Jim_Interp *interp, Jim_Obj *srcPtr, Jim_Obj *dupPtr)
+{
+ /* Copy the internal rep */
+ dupPtr->internalRep = srcPtr->internalRep;
+ /* Need to increment the ref counts */
+ Jim_IncrRefCount(dupPtr->internalRep.dictSubstValue.varNameObjPtr);
+ Jim_IncrRefCount(dupPtr->internalRep.dictSubstValue.indexObjPtr);
+}
+
/* Note: The object *must* be in dict-sugar format */
static void SetDictSubstFromAny(Jim_Interp *interp, Jim_Obj *objPtr)
{