summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2012-12-13 13:01:49 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2012-12-13 13:01:49 (GMT)
commitfacce70703408ad26f669fab0374224cf1d0b2eb (patch)
tree3a0e35b2ff7a25ede71cd8d0585df70c1c245625 /generic
parent26f4ba76ca7de932401313aa8bb90cc386861083 (diff)
parent9918a06afa1ecf70ae09e97275c71932f41648e3 (diff)
downloadtcl-facce70703408ad26f669fab0374224cf1d0b2eb.zip
tcl-facce70703408ad26f669fab0374224cf1d0b2eb.tar.gz
tcl-facce70703408ad26f669fab0374224cf1d0b2eb.tar.bz2
merge trunk
Diffstat (limited to 'generic')
-rw-r--r--generic/tcl.h12
-rw-r--r--generic/tclInt.h28
2 files changed, 22 insertions, 18 deletions
diff --git a/generic/tcl.h b/generic/tcl.h
index 162983b..f7d54b5 100644
--- a/generic/tcl.h
+++ b/generic/tcl.h
@@ -681,10 +681,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);
@@ -2310,7 +2307,12 @@ TCLAPI 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 *_objPtr = (objPtr); \
+ if (_objPtr->refCount-- < 2) { \
+ TclFreeObj(_objPtr); \
+ } \
+ } while(0)
# define Tcl_IsShared(objPtr) \
((objPtr)->refCount > 1)
#endif
diff --git a/generic/tclInt.h b/generic/tclInt.h
index 0efb1b6..7c699c9 100644
--- a/generic/tclInt.h
+++ b/generic/tclInt.h
@@ -3934,24 +3934,26 @@ typedef const char *TclDTraceStr;
* Invalidate the string rep first so we can use the bytes value for our
* pointer chain, and signal an obj deletion (as opposed to shimmering) with
* 'length == -1'.
- * Use empty 'if ; else' to handle use in unbraced outer if/else conditions.
*/
# define TclDecrRefCount(objPtr) \
- if (--(objPtr)->refCount > 0) ; else { \
- if (!(objPtr)->typePtr || !(objPtr)->typePtr->freeIntRepProc) { \
- TCL_DTRACE_OBJ_FREE(objPtr); \
- if ((objPtr)->bytes \
- && ((objPtr)->bytes != tclEmptyStringRep)) { \
- ckfree((char *) (objPtr)->bytes); \
+ do { \
+ Tcl_Obj *_objPtr = (objPtr); \
+ if (_objPtr->refCount-- < 2) { \
+ if (!_objPtr->typePtr || !_objPtr->typePtr->freeIntRepProc) { \
+ TCL_DTRACE_OBJ_FREE(_objPtr); \
+ if (_objPtr->bytes \
+ && (_objPtr->bytes != tclEmptyStringRep)) { \
+ ckfree((char *) _objPtr->bytes); \
+ } \
+ _objPtr->length = -1; \
+ TclFreeObjStorage(_objPtr); \
+ TclIncrObjsFreed(); \
+ } else { \
+ TclFreeObj(_objPtr); \
} \
- (objPtr)->length = -1; \
- TclFreeObjStorage(objPtr); \
- TclIncrObjsFreed(); \
- } else { \
- TclFreeObj(objPtr); \
} \
- }
+ } while(0)
#if defined(PURIFY)