summaryrefslogtreecommitdiffstats
path: root/generic/tclDictObj.c
diff options
context:
space:
mode:
Diffstat (limited to 'generic/tclDictObj.c')
-rw-r--r--generic/tclDictObj.c99
1 files changed, 45 insertions, 54 deletions
diff --git a/generic/tclDictObj.c b/generic/tclDictObj.c
index b4249b8..e92e174 100644
--- a/generic/tclDictObj.c
+++ b/generic/tclDictObj.c
@@ -129,7 +129,7 @@ typedef struct Dict {
* the dictionary. Used for doing traversal of
* the entries in the order that they are
* created. */
- unsigned int epoch; /* Epoch counter */
+ size_t epoch; /* Epoch counter */
size_t refCount; /* Reference counter (see above) */
Tcl_Obj *chain; /* Linked list used for invalidating the
* string representations of updated nested
@@ -228,10 +228,10 @@ AllocChainEntry(
Tcl_Obj *objPtr = (Tcl_Obj *)keyPtr;
ChainEntry *cPtr;
- cPtr = (ChainEntry *)ckalloc(sizeof(ChainEntry));
+ cPtr = (ChainEntry *)Tcl_Alloc(sizeof(ChainEntry));
cPtr->entry.key.objPtr = objPtr;
Tcl_IncrRefCount(objPtr);
- cPtr->entry.clientData = NULL;
+ Tcl_SetHashValue(&cPtr->entry, NULL);
cPtr->prevPtr = cPtr->nextPtr = NULL;
return &cPtr->entry;
@@ -359,7 +359,7 @@ DupDictInternalRep(
Tcl_Obj *srcPtr,
Tcl_Obj *copyPtr)
{
- Dict *oldDict, *newDict = (Dict *)ckalloc(sizeof(Dict));
+ Dict *oldDict, *newDict = (Dict *)Tcl_Alloc(sizeof(Dict));
ChainEntry *cPtr;
DictGetInternalRep(srcPtr, oldDict);
@@ -454,7 +454,7 @@ DeleteDict(
Dict *dict)
{
DeleteChainTable(dict);
- ckfree(dict);
+ Tcl_Free(dict);
}
/*
@@ -488,7 +488,7 @@ UpdateStringOfDict(
Dict *dict;
ChainEntry *cPtr;
Tcl_Obj *keyPtr, *valuePtr;
- int i, length, bytesNeeded = 0;
+ size_t i, length, bytesNeeded = 0;
const char *elem;
char *dst;
@@ -497,7 +497,7 @@ UpdateStringOfDict(
* is not exposed by any API function...
*/
- int numElems;
+ size_t numElems;
DictGetInternalRep(dictPtr, dict);
@@ -518,7 +518,7 @@ UpdateStringOfDict(
if (numElems <= LOCAL_SIZE) {
flagPtr = localFlags;
} else {
- flagPtr = (char *)ckalloc(numElems);
+ flagPtr = (char *)Tcl_Alloc(numElems);
}
for (i=0,cPtr=dict->entryChainHead; i<numElems; i+=2,cPtr=cPtr->nextPtr) {
/*
@@ -528,22 +528,12 @@ UpdateStringOfDict(
flagPtr[i] = ( i ? TCL_DONT_QUOTE_HASH : 0 );
keyPtr = (Tcl_Obj *)Tcl_GetHashKey(&dict->table, &cPtr->entry);
- elem = TclGetStringFromObj(keyPtr, &length);
+ elem = Tcl_GetStringFromObj(keyPtr, &length);
bytesNeeded += TclScanElement(elem, length, flagPtr+i);
- if (bytesNeeded < 0) {
- Tcl_Panic("max size for a Tcl value (%d bytes) exceeded", INT_MAX);
- }
-
flagPtr[i+1] = TCL_DONT_QUOTE_HASH;
valuePtr = (Tcl_Obj *)Tcl_GetHashValue(&cPtr->entry);
- elem = TclGetStringFromObj(valuePtr, &length);
+ elem = Tcl_GetStringFromObj(valuePtr, &length);
bytesNeeded += TclScanElement(elem, length, flagPtr+i+1);
- if (bytesNeeded < 0) {
- Tcl_Panic("max size for a Tcl value (%d bytes) exceeded", INT_MAX);
- }
- }
- if (bytesNeeded > INT_MAX - numElems + 1) {
- Tcl_Panic("max size for a Tcl value (%d bytes) exceeded", INT_MAX);
}
bytesNeeded += numElems;
@@ -556,13 +546,13 @@ UpdateStringOfDict(
for (i=0,cPtr=dict->entryChainHead; i<numElems; i+=2,cPtr=cPtr->nextPtr) {
flagPtr[i] |= ( i ? TCL_DONT_QUOTE_HASH : 0 );
keyPtr = (Tcl_Obj *)Tcl_GetHashKey(&dict->table, &cPtr->entry);
- elem = TclGetStringFromObj(keyPtr, &length);
+ elem = Tcl_GetStringFromObj(keyPtr, &length);
dst += TclConvertElement(elem, length, dst, flagPtr[i]);
*dst++ = ' ';
flagPtr[i+1] |= TCL_DONT_QUOTE_HASH;
valuePtr = (Tcl_Obj *)Tcl_GetHashValue(&cPtr->entry);
- elem = TclGetStringFromObj(valuePtr, &length);
+ elem = Tcl_GetStringFromObj(valuePtr, &length);
dst += TclConvertElement(elem, length, dst, flagPtr[i+1]);
*dst++ = ' ';
}
@@ -570,7 +560,7 @@ UpdateStringOfDict(
(void)Tcl_InitStringRep(dictPtr, NULL, bytesNeeded - 1);
if (flagPtr != localFlags) {
- ckfree(flagPtr);
+ Tcl_Free(flagPtr);
}
}
@@ -601,7 +591,7 @@ SetDictFromAny(
{
Tcl_HashEntry *hPtr;
int isNew;
- Dict *dict = (Dict *)ckalloc(sizeof(Dict));
+ Dict *dict = (Dict *)Tcl_Alloc(sizeof(Dict));
InitChainTable(dict);
@@ -634,7 +624,7 @@ SetDictFromAny(
* convert back.
*/
- (void) Tcl_GetString(objPtr);
+ (void) TclGetString(objPtr);
TclDecrRefCount(discardedValue);
}
@@ -642,14 +632,15 @@ SetDictFromAny(
Tcl_IncrRefCount(objv[i+1]); /* Since hash now holds ref to it */
}
} else {
- int length;
- const char *nextElem = TclGetStringFromObj(objPtr, &length);
+ size_t length;
+ const char *nextElem = Tcl_GetStringFromObj(objPtr, &length);
const char *limit = (nextElem + length);
while (nextElem < limit) {
Tcl_Obj *keyPtr, *valuePtr;
const char *elemStart;
- int elemSize, literal;
+ size_t elemSize;
+ int literal;
if (TclFindDictElement(interp, nextElem, (limit - nextElem),
&elemStart, &nextElem, &elemSize, &literal) != TCL_OK) {
@@ -729,7 +720,7 @@ SetDictFromAny(
}
errorInFindDictElement:
DeleteChainTable(dict);
- ckfree(dict);
+ Tcl_Free(dict);
return TCL_ERROR;
}
@@ -1407,7 +1398,7 @@ Tcl_NewDictObj(void)
TclNewObj(dictPtr);
TclInvalidateStringRep(dictPtr);
- dict = (Dict *)ckalloc(sizeof(Dict));
+ dict = (Dict *)Tcl_Alloc(sizeof(Dict));
InitChainTable(dict);
dict->epoch = 1;
dict->chain = NULL;
@@ -1455,7 +1446,7 @@ Tcl_DbNewDictObj(
TclDbNewObj(dictPtr, file, line);
TclInvalidateStringRep(dictPtr);
- dict = (Dict *)ckalloc(sizeof(Dict));
+ dict = (Dict *)Tcl_Alloc(sizeof(Dict));
InitChainTable(dict);
dict->epoch = 1;
dict->chain = NULL;
@@ -1495,7 +1486,7 @@ Tcl_DbNewDictObj(
static int
DictCreateCmd(
- TCL_UNUSED(ClientData),
+ TCL_UNUSED(void *),
Tcl_Interp *interp,
int objc,
Tcl_Obj *const *objv)
@@ -1545,7 +1536,7 @@ DictCreateCmd(
static int
DictGetCmd(
- TCL_UNUSED(ClientData),
+ TCL_UNUSED(void *),
Tcl_Interp *interp,
int objc,
Tcl_Obj *const *objv)
@@ -1638,7 +1629,7 @@ DictGetCmd(
static int
DictGetDefCmd(
- TCL_UNUSED(ClientData),
+ TCL_UNUSED(void *),
Tcl_Interp *interp,
int objc,
Tcl_Obj *const *objv)
@@ -1703,7 +1694,7 @@ DictGetDefCmd(
static int
DictReplaceCmd(
- TCL_UNUSED(ClientData),
+ TCL_UNUSED(void *),
Tcl_Interp *interp,
int objc,
Tcl_Obj *const *objv)
@@ -1751,7 +1742,7 @@ DictReplaceCmd(
static int
DictRemoveCmd(
- TCL_UNUSED(ClientData),
+ TCL_UNUSED(void *),
Tcl_Interp *interp,
int objc,
Tcl_Obj *const *objv)
@@ -1799,7 +1790,7 @@ DictRemoveCmd(
static int
DictMergeCmd(
- TCL_UNUSED(ClientData),
+ TCL_UNUSED(void *),
Tcl_Interp *interp,
int objc,
Tcl_Obj *const *objv)
@@ -1886,7 +1877,7 @@ DictMergeCmd(
static int
DictKeysCmd(
- TCL_UNUSED(ClientData),
+ TCL_UNUSED(void *),
Tcl_Interp *interp,
int objc,
Tcl_Obj *const *objv)
@@ -1965,7 +1956,7 @@ DictKeysCmd(
static int
DictValuesCmd(
- TCL_UNUSED(ClientData),
+ TCL_UNUSED(void *),
Tcl_Interp *interp,
int objc,
Tcl_Obj *const *objv)
@@ -2025,7 +2016,7 @@ DictValuesCmd(
static int
DictSizeCmd(
- TCL_UNUSED(ClientData),
+ TCL_UNUSED(void *),
Tcl_Interp *interp,
int objc,
Tcl_Obj *const *objv)
@@ -2063,7 +2054,7 @@ DictSizeCmd(
static int
DictExistsCmd(
- TCL_UNUSED(ClientData),
+ TCL_UNUSED(void *),
Tcl_Interp *interp,
int objc,
Tcl_Obj *const *objv)
@@ -2105,7 +2096,7 @@ DictExistsCmd(
static int
DictInfoCmd(
- TCL_UNUSED(ClientData),
+ TCL_UNUSED(void *),
Tcl_Interp *interp,
int objc,
Tcl_Obj *const *objv)
@@ -2125,7 +2116,7 @@ DictInfoCmd(
statsStr = Tcl_HashStats(&dict->table);
Tcl_SetObjResult(interp, Tcl_NewStringObj(statsStr, -1));
- ckfree(statsStr);
+ Tcl_Free(statsStr);
return TCL_OK;
}
@@ -2149,7 +2140,7 @@ DictInfoCmd(
static int
DictIncrCmd(
- TCL_UNUSED(ClientData),
+ TCL_UNUSED(void *),
Tcl_Interp *interp,
int objc,
Tcl_Obj *const *objv)
@@ -2270,7 +2261,7 @@ DictIncrCmd(
static int
DictLappendCmd(
- TCL_UNUSED(ClientData),
+ TCL_UNUSED(void *),
Tcl_Interp *interp,
int objc,
Tcl_Obj *const *objv)
@@ -2357,7 +2348,7 @@ DictLappendCmd(
static int
DictAppendCmd(
- TCL_UNUSED(ClientData),
+ TCL_UNUSED(void *),
Tcl_Interp *interp,
int objc,
Tcl_Obj *const *objv)
@@ -2459,7 +2450,7 @@ DictAppendCmd(
static int
DictForNRCmd(
- TCL_UNUSED(ClientData),
+ TCL_UNUSED(void *),
Tcl_Interp *interp,
int objc,
Tcl_Obj *const *objv)
@@ -2654,7 +2645,7 @@ DictForLoopCallback(
static int
DictMapNRCmd(
- TCL_UNUSED(ClientData),
+ TCL_UNUSED(void *),
Tcl_Interp *interp,
int objc,
Tcl_Obj *const *objv)
@@ -2866,7 +2857,7 @@ DictMapLoopCallback(
static int
DictSetCmd(
- TCL_UNUSED(ClientData),
+ TCL_UNUSED(void *),
Tcl_Interp *interp,
int objc,
Tcl_Obj *const *objv)
@@ -2926,7 +2917,7 @@ DictSetCmd(
static int
DictUnsetCmd(
- TCL_UNUSED(ClientData),
+ TCL_UNUSED(void *),
Tcl_Interp *interp,
int objc,
Tcl_Obj *const *objv)
@@ -2985,7 +2976,7 @@ DictUnsetCmd(
static int
DictFilterCmd(
- TCL_UNUSED(ClientData),
+ TCL_UNUSED(void *),
Tcl_Interp *interp,
int objc,
Tcl_Obj *const *objv)
@@ -3270,7 +3261,7 @@ DictFilterCmd(
static int
DictUpdateCmd(
- TCL_UNUSED(ClientData),
+ TCL_UNUSED(void *),
Tcl_Interp *interp,
int objc,
Tcl_Obj *const *objv)
@@ -3300,7 +3291,7 @@ DictUpdateCmd(
}
if (objPtr == NULL) {
/* ??? */
- Tcl_UnsetVar2(interp, Tcl_GetString(objv[i+1]), NULL, 0);
+ Tcl_UnsetVar2(interp, TclGetString(objv[i+1]), NULL, 0);
} else if (Tcl_ObjSetVar2(interp, objv[i+1], NULL, objPtr,
TCL_LEAVE_ERR_MSG) == NULL) {
TclDecrRefCount(dictPtr);
@@ -3428,7 +3419,7 @@ FinalizeDictUpdate(
static int
DictWithCmd(
- TCL_UNUSED(ClientData),
+ TCL_UNUSED(void *),
Tcl_Interp *interp,
int objc,
Tcl_Obj *const *objv)