summaryrefslogtreecommitdiffstats
path: root/generic/tkText.c
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2017-01-18 12:44:22 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2017-01-18 12:44:22 (GMT)
commitc558898981a43637a64c17a40fd816ae41991961 (patch)
treef00289fc7ee4cef9794d712add3048d86320a16e /generic/tkText.c
parentec5e2f38d3eb0132822396f9b105d4cc5c78e86b (diff)
downloadtk-c558898981a43637a64c17a40fd816ae41991961.zip
tk-c558898981a43637a64c17a40fd816ae41991961.tar.gz
tk-c558898981a43637a64c17a40fd816ae41991961.tar.bz2
Change more refCount checks to the form "(...refCount-- <= 1)", so no separate decrement and compare is necessary. This allows (in the future) the same code to work when refCount becomes unsigned (which at least doubles the range). No functional change.
Diffstat (limited to 'generic/tkText.c')
-rw-r--r--generic/tkText.c12
1 files changed, 4 insertions, 8 deletions
diff --git a/generic/tkText.c b/generic/tkText.c
index 412a7f2..6ff1db9 100644
--- a/generic/tkText.c
+++ b/generic/tkText.c
@@ -1570,8 +1570,7 @@ TextWidgetObjCmd(
}
done:
- textPtr->refCount--;
- if (textPtr->refCount == 0) {
+ if (textPtr->refCount-- <= 1) {
ckfree(textPtr);
}
return result;
@@ -1964,9 +1963,7 @@ DestroyText(
* portion of the text widget.
*/
- sharedTextPtr->refCount--;
-
- if (sharedTextPtr->refCount > 0) {
+ if (sharedTextPtr->refCount-- > 1) {
TkBTreeRemoveClient(sharedTextPtr->tree, textPtr);
/*
@@ -2042,13 +2039,12 @@ DestroyText(
}
textPtr->tkwin = NULL;
- textPtr->refCount--;
Tcl_DeleteCommandFromToken(textPtr->interp, textPtr->widgetCmd);
if (textPtr->afterSyncCmd){
Tcl_DecrRefCount(textPtr->afterSyncCmd);
textPtr->afterSyncCmd = NULL;
}
- if (textPtr->refCount == 0) {
+ if (textPtr->refCount-- <= 1) {
ckfree(textPtr);
}
}
@@ -5526,7 +5522,7 @@ RunAfterSyncCmd(
* The widget has been deleted. Don't do anything.
*/
- if (--textPtr->refCount == 0) {
+ if (textPtr->refCount-- <= 1) {
ckfree((char *) textPtr);
}
return;