diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2020-09-20 21:32:35 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2020-09-20 21:32:35 (GMT) |
commit | 9e43cbb9739ecfd05d38ff31a49050a0eb04505b (patch) | |
tree | 9f03fad624c027d190e47cb88ee31518a59d49e5 | |
parent | 7a56ff406f3244d777f60d9a5e0da1e5e08f3ef9 (diff) | |
download | tcl-9e43cbb9739ecfd05d38ff31a49050a0eb04505b.zip tcl-9e43cbb9739ecfd05d38ff31a49050a0eb04505b.tar.gz tcl-9e43cbb9739ecfd05d38ff31a49050a0eb04505b.tar.bz2 |
Improve TclInvalidateStringRep() macro such that (objPtr) is only evaluated once. Addation brackets in TclHasStringRep() macro
-rw-r--r-- | generic/tcl.h | 2 | ||||
-rw-r--r-- | generic/tclInt.h | 15 |
2 files changed, 10 insertions, 7 deletions
diff --git a/generic/tcl.h b/generic/tcl.h index 458072a..914f62b 100644 --- a/generic/tcl.h +++ b/generic/tcl.h @@ -2517,7 +2517,7 @@ EXTERN void Tcl_GetMemoryInfo(Tcl_DString *dsPtr); # define Tcl_DecrRefCount(objPtr) \ do { \ Tcl_Obj *_objPtr = (objPtr); \ - if ((_objPtr)->refCount-- <= 1) { \ + if (_objPtr->refCount-- <= 1) { \ TclFreeObj(_objPtr); \ } \ } while(0) diff --git a/generic/tclInt.h b/generic/tclInt.h index 3dbffeb..f2f097c 100644 --- a/generic/tclInt.h +++ b/generic/tclInt.h @@ -4369,15 +4369,18 @@ MODULE_SCOPE void TclDbInitNewObj(Tcl_Obj *objPtr, const char *file, */ #define TclInvalidateStringRep(objPtr) \ - if (objPtr->bytes != NULL) { \ - if (objPtr->bytes != tclEmptyStringRep) { \ - ckfree((char *) objPtr->bytes); \ + do { \ + Tcl_Obj *_isobjPtr = (Tcl_Obj *)(objPtr); \ + if (_isobjPtr->bytes != NULL) { \ + if (_isobjPtr->bytes != tclEmptyStringRep) { \ + ckfree((char *)_isobjPtr->bytes); \ + } \ + _isobjPtr->bytes = NULL; \ } \ - objPtr->bytes = NULL; \ - } + } while (0) #define TclHasStringRep(objPtr) \ - (objPtr->bytes != NULL) + ((objPtr)->bytes != NULL) /* *---------------------------------------------------------------- |