From 27ce2290a6e107aa7e2b8a5995fa32e32106546c Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Tue, 30 Jun 2015 21:41:18 +0000 Subject: Consistancy in refcount management. --- generic/tclCompile.c | 4 ++-- generic/tclExecute.c | 2 +- generic/tclObj.c | 6 +++--- generic/tclProc.c | 6 +++--- generic/tclVar.c | 4 ++-- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/generic/tclCompile.c b/generic/tclCompile.c index a552f39..98756ea 100644 --- a/generic/tclCompile.c +++ b/generic/tclCompile.c @@ -978,7 +978,7 @@ FreeByteCodeInternalRep( register ByteCode *codePtr = objPtr->internalRep.twoPtrValue.ptr1; objPtr->typePtr = NULL; - if (codePtr->refCount-- < 2) { + if (codePtr->refCount-- <= 1) { TclCleanupByteCode(codePtr); } } @@ -1364,7 +1364,7 @@ FreeSubstCodeInternalRep( register ByteCode *codePtr = objPtr->internalRep.twoPtrValue.ptr1; objPtr->typePtr = NULL; - if (codePtr->refCount-- < 2) { + if (codePtr->refCount-- <= 1) { TclCleanupByteCode(codePtr); } } diff --git a/generic/tclExecute.c b/generic/tclExecute.c index 5b053a6..6fc6b6b 100644 --- a/generic/tclExecute.c +++ b/generic/tclExecute.c @@ -1649,7 +1649,7 @@ FreeExprCodeInternalRep( ByteCode *codePtr = objPtr->internalRep.twoPtrValue.ptr1; objPtr->typePtr = NULL; - if (codePtr->refCount-- < 2) { + if (codePtr->refCount-- <= 1) { TclCleanupByteCode(codePtr); } } diff --git a/generic/tclObj.c b/generic/tclObj.c index 80a3e31..15d874f 100644 --- a/generic/tclObj.c +++ b/generic/tclObj.c @@ -3803,7 +3803,7 @@ Tcl_DbDecrRefCount( # endif /* TCL_THREADS */ #endif /* TCL_MEM_DEBUG */ - if (--(objPtr)->refCount <= 0) { + if (objPtr->refCount-- <= 1) { TclFreeObj(objPtr); } } @@ -4288,7 +4288,7 @@ FreeCmdNameInternalRep( * there are no more uses, free the ResolvedCmdName structure. */ - if (resPtr->refCount-- == 1) { + if (resPtr->refCount-- <= 1) { /* * Now free the cached command, unless it is still in its hash * table or if there are other references to it from other cmdName @@ -4404,7 +4404,7 @@ SetCmdNameFromAny( Command *oldCmdPtr = resPtr->cmdPtr; - if (--oldCmdPtr->refCount == 0) { + if (oldCmdPtr->refCount-- <= 1) { TclCleanupCommandMacro(oldCmdPtr); } } else { diff --git a/generic/tclProc.c b/generic/tclProc.c index 6ffbd90..2679bf1 100644 --- a/generic/tclProc.c +++ b/generic/tclProc.c @@ -1842,7 +1842,7 @@ InterpProcNR2( TCL_DTRACE_PROC_RETURN(l < iPtr->varFramePtr->objc ? TclGetString(iPtr->varFramePtr->objv[l]) : NULL, result); } - if (--procPtr->refCount <= 0) { + if (procPtr->refCount-- <= 1) { TclProcCleanupProc(procPtr); } @@ -2403,7 +2403,7 @@ ProcBodyFree( { Proc *procPtr = objPtr->internalRep.twoPtrValue.ptr1; - if (procPtr->refCount-- < 2) { + if (procPtr->refCount-- <= 1) { TclProcCleanupProc(procPtr); } } @@ -2446,7 +2446,7 @@ FreeLambdaInternalRep( Proc *procPtr = objPtr->internalRep.twoPtrValue.ptr1; Tcl_Obj *nsObjPtr = objPtr->internalRep.twoPtrValue.ptr2; - if (procPtr->refCount-- == 1) { + if (procPtr->refCount-- <= 1) { TclProcCleanupProc(procPtr); } TclDecrRefCount(nsObjPtr); diff --git a/generic/tclVar.c b/generic/tclVar.c index 8fb89cd..97aa7ab 100644 --- a/generic/tclVar.c +++ b/generic/tclVar.c @@ -5713,8 +5713,8 @@ FreeNsVarName( { register Var *varPtr = objPtr->internalRep.twoPtrValue.ptr2; - if (TclIsVarInHash(varPtr)) { - if ((varPtr->refCount-- == 1) && TclIsVarUndefined(varPtr)) { + if (TclIsVarInHash(varPtr) && TclIsVarUndefined(varPtr)) { + if ((varPtr->refCount-- <= 1)) { CleanupVar(varPtr, NULL); } } -- cgit v0.12