diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2012-12-13 10:48:04 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2012-12-13 10:48:04 (GMT) |
commit | 2f1b92ba12fe6dcbad5a26a6dc6f6be837155049 (patch) | |
tree | 22840652c50c747117ea54578e7fef1c5e98356f | |
parent | 6d80a782d0346ad68115511a1d4813a920c489ca (diff) | |
download | tcl-2f1b92ba12fe6dcbad5a26a6dc6f6be837155049.zip tcl-2f1b92ba12fe6dcbad5a26a6dc6f6be837155049.tar.gz tcl-2f1b92ba12fe6dcbad5a26a6dc6f6be837155049.tar.bz2 |
Fix Tcl_DecrRefCount macro, not to refer to its objPtr parameter twice.
-rw-r--r-- | generic/tcl.h | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/generic/tcl.h b/generic/tcl.h index 36077e6..48fe062 100644 --- a/generic/tcl.h +++ b/generic/tcl.h @@ -810,9 +810,7 @@ typedef struct Tcl_Obj { * 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. + * definition. */ void Tcl_IncrRefCount _ANSI_ARGS_((Tcl_Obj *objPtr)); void Tcl_DecrRefCount _ANSI_ARGS_((Tcl_Obj *objPtr)); @@ -833,7 +831,12 @@ int Tcl_IsShared _ANSI_ARGS_((Tcl_Obj *objPtr)); * 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 |