diff options
| author | dgp <dgp@users.sourceforge.net> | 2018-11-13 16:37:31 (GMT) |
|---|---|---|
| committer | dgp <dgp@users.sourceforge.net> | 2018-11-13 16:37:31 (GMT) |
| commit | 12b55ed51dea5ca63f53c6aca59bfa5091984e49 (patch) | |
| tree | 468a709c54774ca31918d2a826157f1fcd8df0ab /generic/tclObj.c | |
| parent | 336de438e2cbe2e1933ac3a79292610831f260c1 (diff) | |
| download | tcl-12b55ed51dea5ca63f53c6aca59bfa5091984e49.zip tcl-12b55ed51dea5ca63f53c6aca59bfa5091984e49.tar.gz tcl-12b55ed51dea5ca63f53c6aca59bfa5091984e49.tar.bz2 | |
Implement TIP 506
Diffstat (limited to 'generic/tclObj.c')
| -rw-r--r-- | generic/tclObj.c | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/generic/tclObj.c b/generic/tclObj.c index db9f896..f3df304 100644 --- a/generic/tclObj.c +++ b/generic/tclObj.c @@ -3221,6 +3221,68 @@ TclGetNumberFromObj( /* *---------------------------------------------------------------------- * + * Tcl_IncrRefCount -- + * + * Increments the reference count of the object. + * + * Results: + * None. + * + *---------------------------------------------------------------------- + */ + +void +Tcl_IncrRefCount( + Tcl_Obj *objPtr) /* The object we are registering a reference to. */ +{ + ++(objPtr)->refCount; +} + +/* + *---------------------------------------------------------------------- + * + * Tcl_DecrRefCount -- + * + * Decrements the reference count of the object. + * + * Results: + * None. + * + *---------------------------------------------------------------------- + */ + +void +Tcl_DecrRefCount( + Tcl_Obj *objPtr) /* The object we are releasing a reference to. */ +{ + if (objPtr->refCount-- <= 1) { + TclFreeObj(objPtr); + } +} + +/* + *---------------------------------------------------------------------- + * + * Tcl_IsShared -- + * + * Tests if the object has a ref count greater than one. + * + * Results: + * Boolean value that is the result of the test. + * + *---------------------------------------------------------------------- + */ + +int +Tcl_IsShared( + Tcl_Obj *objPtr) /* The object to test for being shared. */ +{ + return ((objPtr)->refCount > 1); +} + +/* + *---------------------------------------------------------------------- + * * Tcl_DbIncrRefCount -- * * This function is normally called when debugging: i.e., when |
