summaryrefslogtreecommitdiffstats
path: root/generic/tclDictObj.c
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2016-11-24 11:57:07 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2016-11-24 11:57:07 (GMT)
commit2290210ff1e4282f665fd6b6dfaf4142220f5559 (patch)
treeb9febc0881a58eee6a89d5510caaed05af60b537 /generic/tclDictObj.c
parent53f3b03647b0cc4baaac0fea20bcbf36f3a06702 (diff)
parentc8d9ab8790cf3ce9e8a7ef9bc1593d7ad97a94cc (diff)
downloadtcl-2290210ff1e4282f665fd6b6dfaf4142220f5559.zip
tcl-2290210ff1e4282f665fd6b6dfaf4142220f5559.tar.gz
tcl-2290210ff1e4282f665fd6b6dfaf4142220f5559.tar.bz2
merge trunk.
Make epoch in Tcl_DictSearch "unsigned int". This doubles the epoch range here. Use 0 as special value in stead of -1 (so start counting epoch's with 1).
Diffstat (limited to 'generic/tclDictObj.c')
-rw-r--r--generic/tclDictObj.c36
1 files changed, 17 insertions, 19 deletions
diff --git a/generic/tclDictObj.c b/generic/tclDictObj.c
index 9fad0c8..ea3be1a 100644
--- a/generic/tclDictObj.c
+++ b/generic/tclDictObj.c
@@ -141,8 +141,8 @@ typedef struct Dict {
* the dictionary. Used for doing traversal of
* the entries in the order that they are
* created. */
- int epoch; /* Epoch counter */
- int refcount; /* Reference counter (see above) */
+ unsigned int epoch; /* Epoch counter */
+ size_t refCount; /* Reference counter (see above) */
Tcl_Obj *chain; /* Linked list used for invalidating the
* string representations of updated nested
* dictionaries. */
@@ -390,9 +390,9 @@ DupDictInternalRep(
* Initialise other fields.
*/
- newDict->epoch = 0;
+ newDict->epoch = 1;
newDict->chain = NULL;
- newDict->refcount = 1;
+ newDict->refCount = 1;
/*
* Store in the object.
@@ -427,8 +427,7 @@ FreeDictInternalRep(
{
Dict *dict = DICT(dictPtr);
- dict->refcount--;
- if (dict->refcount <= 0) {
+ if (dict->refCount-- <= 1) {
DeleteDict(dict);
}
dictPtr->typePtr = NULL;
@@ -708,9 +707,9 @@ SetDictFromAny(
*/
TclFreeIntRep(objPtr);
- dict->epoch = 0;
+ dict->epoch = 1;
dict->chain = NULL;
- dict->refcount = 1;
+ dict->refCount = 1;
DICT(objPtr) = dict;
objPtr->internalRep.twoPtrValue.ptr2 = NULL;
objPtr->typePtr = &tclDictType;
@@ -1107,14 +1106,14 @@ Tcl_DictObjFirst(
dict = DICT(dictPtr);
cPtr = dict->entryChainHead;
if (cPtr == NULL) {
- searchPtr->epoch = -1;
+ searchPtr->epoch = 0;
*donePtr = 1;
} else {
*donePtr = 0;
searchPtr->dictionaryPtr = (Tcl_Dict) dict;
searchPtr->epoch = dict->epoch;
searchPtr->next = cPtr->nextPtr;
- dict->refcount++;
+ dict->refCount++;
if (keyPtrPtr != NULL) {
*keyPtrPtr = Tcl_GetHashKey(&dict->table, &cPtr->entry);
}
@@ -1168,7 +1167,7 @@ Tcl_DictObjNext(
* If the searh is done; we do no work.
*/
- if (searchPtr->epoch == -1) {
+ if (searchPtr->epoch == 0) {
*donePtr = 1;
return;
}
@@ -1225,11 +1224,10 @@ Tcl_DictObjDone(
{
Dict *dict;
- if (searchPtr->epoch != -1) {
- searchPtr->epoch = -1;
+ if (searchPtr->epoch != 0) {
+ searchPtr->epoch = 0;
dict = (Dict *) searchPtr->dictionaryPtr;
- dict->refcount--;
- if (dict->refcount <= 0) {
+ if (dict->refCount-- <= 1) {
DeleteDict(dict);
}
}
@@ -1379,9 +1377,9 @@ Tcl_NewDictObj(void)
TclInvalidateStringRep(dictPtr);
dict = ckalloc(sizeof(Dict));
InitChainTable(dict);
- dict->epoch = 0;
+ dict->epoch = 1;
dict->chain = NULL;
- dict->refcount = 1;
+ dict->refCount = 1;
DICT(dictPtr) = dict;
dictPtr->internalRep.twoPtrValue.ptr2 = NULL;
dictPtr->typePtr = &tclDictType;
@@ -1429,9 +1427,9 @@ Tcl_DbNewDictObj(
TclInvalidateStringRep(dictPtr);
dict = ckalloc(sizeof(Dict));
InitChainTable(dict);
- dict->epoch = 0;
+ dict->epoch = 1;
dict->chain = NULL;
- dict->refcount = 1;
+ dict->refCount = 1;
DICT(dictPtr) = dict;
dictPtr->internalRep.twoPtrValue.ptr2 = NULL;
dictPtr->typePtr = &tclDictType;