summaryrefslogtreecommitdiffstats
path: root/generic/tcl.h
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2012-12-13 11:00:13 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2012-12-13 11:00:13 (GMT)
commitf6e3461b2afc38d0ae86ecd6424de16e5b555ff4 (patch)
treee9f1de6715632fe894e2c0886b56197f12dedf13 /generic/tcl.h
parentf58d1bd1d652773fa234b05b9bda55f7d1a9ea42 (diff)
parentb8f7032b2378ad5140908f50da466efe081d0afb (diff)
downloadtcl-f6e3461b2afc38d0ae86ecd6424de16e5b555ff4.zip
tcl-f6e3461b2afc38d0ae86ecd6424de16e5b555ff4.tar.gz
tcl-f6e3461b2afc38d0ae86ecd6424de16e5b555ff4.tar.bz2
Fix Tcl_DecrRefCount macro, not to refer to its objPtr parameter twice.
Diffstat (limited to 'generic/tcl.h')
-rw-r--r--generic/tcl.h12
1 files changed, 7 insertions, 5 deletions
diff --git a/generic/tcl.h b/generic/tcl.h
index e921ec5..b253db7 100644
--- a/generic/tcl.h
+++ b/generic/tcl.h
@@ -798,10 +798,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 _ANSI_ARGS_((Tcl_Obj *objPtr));
@@ -2315,7 +2312,12 @@ EXTERN void Tcl_GetMemoryInfo _ANSI_ARGS_((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