diff options
author | pooryorick <com.digitalsmarties@pooryorick.com> | 2023-05-17 12:26:11 (GMT) |
---|---|---|
committer | pooryorick <com.digitalsmarties@pooryorick.com> | 2023-05-17 12:26:11 (GMT) |
commit | ac555b905c136e91ee92a89d6b225b9a46851e8d (patch) | |
tree | 020a6935435777cb8e313cc5268351a1229fed6a /generic/tclObj.c | |
parent | 599038222278a31912d42c4a6db1aee88052c40b (diff) | |
download | tcl-ac555b905c136e91ee92a89d6b225b9a46851e8d.zip tcl-ac555b905c136e91ee92a89d6b225b9a46851e8d.tar.gz tcl-ac555b905c136e91ee92a89d6b225b9a46851e8d.tar.bz2 |
New functions: TclUndoRefCount() and TclDictGetSize().
Diffstat (limited to 'generic/tclObj.c')
-rw-r--r-- | generic/tclObj.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/generic/tclObj.c b/generic/tclObj.c index 58eb71d..ba3c626 100644 --- a/generic/tclObj.c +++ b/generic/tclObj.c @@ -3780,6 +3780,28 @@ Tcl_DecrRefCount( /* *---------------------------------------------------------------------- * + * TclUndoRefCount -- + * + * Decrement the refCount of objPtr without causing it to be freed if it + * drops from 1 to 0. This allows a function increment a refCount but + * then decrement it and still be able to pass return it to a caller, + * possibly with a refCount of 0. The caller must have previously + * incremented the refCount. + * + *---------------------------------------------------------------------- + */ +void +TclUndoRefCount( + Tcl_Obj *objPtr) /* The object we are releasing a reference to. */ +{ + if (objPtr->refCount > 0) { + --objPtr->refCount; + } +} + +/* + *---------------------------------------------------------------------- + * * Tcl_IsShared -- * * Tests if the object has a ref count greater than one. |