diff options
author | jan.nijtmans <jan.nijtmans@noemail.net> | 2012-12-13 11:02:15 (GMT) |
---|---|---|
committer | jan.nijtmans <jan.nijtmans@noemail.net> | 2012-12-13 11:02:15 (GMT) |
commit | f8d0e778b9746cbfce87aaca49cbe0eaa4ce2045 (patch) | |
tree | e4d00861fe1bf524826adc3c3653eccbc77dac74 /generic/tcl.h | |
parent | 35a743c61e08470f9afefe1e82951a4af23af050 (diff) | |
parent | 33bc3f551d75032142dc91b452f89a751f5c26e9 (diff) | |
download | tcl-f8d0e778b9746cbfce87aaca49cbe0eaa4ce2045.zip tcl-f8d0e778b9746cbfce87aaca49cbe0eaa4ce2045.tar.gz tcl-f8d0e778b9746cbfce87aaca49cbe0eaa4ce2045.tar.bz2 |
Fix Tcl_DecrRefCount macro, not to refer to its objPtr parameter twice.
FossilOrigin-Name: fb66668b1644184e9d19d32904757591668664c6
Diffstat (limited to 'generic/tcl.h')
-rw-r--r-- | generic/tcl.h | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/generic/tcl.h b/generic/tcl.h index 147672c..5a85c33 100644 --- a/generic/tcl.h +++ b/generic/tcl.h @@ -854,10 +854,7 @@ typedef struct Tcl_Obj { * whether an object is shared (i.e. has reference count > 1). Note: clients * should use Tcl_DecrRefCount() when they are finished using an object, and * should never call TclFreeObj() directly. TclFreeObj() is only defined and - * made public in tcl.h to support Tcl_DecrRefCount's macro definition. Note - * also that Tcl_DecrRefCount() refers to the parameter "obj" twice. This - * means that you should avoid calling it with an expression that is expensive - * to compute or has side effects. + * made public in tcl.h to support Tcl_DecrRefCount's macro definition. */ void Tcl_IncrRefCount(Tcl_Obj *objPtr); @@ -2504,7 +2501,12 @@ EXTERN void Tcl_GetMemoryInfo(Tcl_DString *dsPtr); * http://c2.com/cgi/wiki?TrivialDoWhileLoop */ # define Tcl_DecrRefCount(objPtr) \ - do { if (--(objPtr)->refCount <= 0) TclFreeObj(objPtr); } while(0) + do { \ + Tcl_Obj *obj = (objPtr); \ + if ((obj)->refCount-- < 2) { \ + TclFreeObj(obj); \ + } \ + } while(0) # define Tcl_IsShared(objPtr) \ ((objPtr)->refCount > 1) #endif |