diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2019-06-06 07:59:21 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2019-06-06 07:59:21 (GMT) |
commit | bd4765cf50cf1df6abe07db4cacd8fcae2e950c8 (patch) | |
tree | 958bb8220ddac106c7759510e38d3b961fdf3b04 | |
parent | 10e31bc252115c3c1a4f1892c14c875e37af6e7a (diff) | |
parent | 9d7e696016d924ae175c552e503b4dfb2c806884 (diff) | |
download | tcl-bd4765cf50cf1df6abe07db4cacd8fcae2e950c8.zip tcl-bd4765cf50cf1df6abe07db4cacd8fcae2e950c8.tar.gz tcl-bd4765cf50cf1df6abe07db4cacd8fcae2e950c8.tar.bz2 |
Squelch compiler warnings, but make refCount of type unsigned int.
-rw-r--r-- | generic/tclInt.h | 6 | ||||
-rw-r--r-- | generic/tclLiteral.c | 10 |
2 files changed, 9 insertions, 7 deletions
diff --git a/generic/tclInt.h b/generic/tclInt.h index 933280a..9384295 100644 --- a/generic/tclInt.h +++ b/generic/tclInt.h @@ -569,7 +569,7 @@ typedef struct CommandTrace { struct CommandTrace *nextPtr; /* Next in list of traces associated with a * particular command. */ - size_t refCount; /* Used to ensure this structure is not + unsigned int refCount; /* Used to ensure this structure is not * deleted too early. Keeps track of how many * pieces of code have a pointer to this * structure. */ @@ -1519,11 +1519,11 @@ typedef struct LiteralEntry { * NULL if end of chain. */ Tcl_Obj *objPtr; /* Points to Tcl object that holds the * literal's bytes and length. */ - size_t refCount; /* If in an interpreter's global literal + unsigned int refCount; /* If in an interpreter's global literal * table, the number of ByteCode structures * that share the literal object; the literal * entry can be freed when refCount drops to - * 0. If in a local literal table, (size_t)-1. */ + * 0. If in a local literal table, (unsigned)-1. */ Namespace *nsPtr; /* Namespace in which this literal is used. We * try to avoid sharing literal non-FQ command * names among different namespaces to reduce diff --git a/generic/tclLiteral.c b/generic/tclLiteral.c index 464f565..6407c37 100644 --- a/generic/tclLiteral.c +++ b/generic/tclLiteral.c @@ -227,7 +227,9 @@ TclCreateLiteral( if (flags & LITERAL_ON_HEAP) { ckfree(bytes); } - globalPtr->refCount++; + if (globalPtr->refCount != (unsigned) -1) { + globalPtr->refCount++; + } return objPtr; } } @@ -625,7 +627,7 @@ TclAddLiteralObj( lPtr = &envPtr->literalArrayPtr[objIndex]; lPtr->objPtr = objPtr; Tcl_IncrRefCount(objPtr); - lPtr->refCount = (size_t)-1; /* i.e., unused */ + lPtr->refCount = (unsigned) -1; /* i.e., unused */ lPtr->nextPtr = NULL; if (litPtrPtr) { @@ -848,7 +850,7 @@ TclReleaseLiteral( * literal table entry (decrement the ref count of the object). */ - if (entryPtr->refCount-- <= 1) { + if ((entryPtr->refCount != (unsigned)-1) && (entryPtr->refCount-- <= 1)) { if (prevPtr == NULL) { globalTablePtr->buckets[index] = entryPtr->nextPtr; } else { @@ -1174,7 +1176,7 @@ TclVerifyLocalLiteralTable( for (localPtr=localTablePtr->buckets[i] ; localPtr!=NULL; localPtr=localPtr->nextPtr) { count++; - if (localPtr->refCount != -1) { + if (localPtr->refCount != (size_t)-1) { bytes = TclGetStringFromObj(localPtr->objPtr, &length); Tcl_Panic("%s: local literal \"%.*s\" had bad refCount %d", "TclVerifyLocalLiteralTable", |