summaryrefslogtreecommitdiffstats
path: root/generic/tclDictObj.c
diff options
context:
space:
mode:
Diffstat (limited to 'generic/tclDictObj.c')
-rw-r--r--generic/tclDictObj.c25
1 files changed, 11 insertions, 14 deletions
diff --git a/generic/tclDictObj.c b/generic/tclDictObj.c
index e31d708..ad24017 100644
--- a/generic/tclDictObj.c
+++ b/generic/tclDictObj.c
@@ -485,15 +485,14 @@ static void
UpdateStringOfDict(
Tcl_Obj *dictPtr)
{
-#define LOCAL_SIZE 20
- int localFlags[LOCAL_SIZE], *flagPtr = NULL;
+#define LOCAL_SIZE 64
+ char localFlags[LOCAL_SIZE], *flagPtr = NULL;
Dict *dict = dictPtr->internalRep.twoPtrValue.ptr1;
ChainEntry *cPtr;
Tcl_Obj *keyPtr, *valuePtr;
int i, length, bytesNeeded = 0;
const char *elem;
char *dst;
- const int maxFlags = UINT_MAX / sizeof(int);
/*
* This field is the most useful one in the whole hash structure, and it
@@ -515,10 +514,8 @@ UpdateStringOfDict(
if (numElems <= LOCAL_SIZE) {
flagPtr = localFlags;
- } else if (numElems > maxFlags) {
- Tcl_Panic("max size for a Tcl value (%d bytes) exceeded", INT_MAX);
} else {
- flagPtr = ckalloc(numElems * sizeof(int));
+ flagPtr = ckalloc(numElems);
}
for (i=0,cPtr=dict->entryChainHead; i<numElems; i+=2,cPtr=cPtr->nextPtr) {
/*
@@ -622,7 +619,7 @@ SetDictFromAny(
}
for (i=0 ; i<objc ; i+=2) {
-
+
/* Store key and value in the hash table we're building. */
hPtr = CreateChainEntry(dict, objv[i], &isNew);
if (!isNew) {
@@ -1972,7 +1969,7 @@ DictSizeCmd(
}
result = Tcl_DictObjSize(interp, objv[1], &size);
if (result == TCL_OK) {
- Tcl_SetObjResult(interp, Tcl_NewIntObj(size));
+ Tcl_SetObjResult(interp, Tcl_NewLongObj(size));
}
return result;
}
@@ -2014,9 +2011,9 @@ DictExistsCmd(
if (dictPtr == NULL || dictPtr == DICT_PATH_NON_EXISTENT
|| Tcl_DictObjGet(interp, dictPtr, objv[objc-1],
&valuePtr) != TCL_OK) {
- Tcl_SetObjResult(interp, Tcl_NewBooleanObj(0));
+ Tcl_SetObjResult(interp, Tcl_NewLongObj(0));
} else {
- Tcl_SetObjResult(interp, Tcl_NewBooleanObj(valuePtr != NULL));
+ Tcl_SetObjResult(interp, Tcl_NewLongObj(valuePtr != NULL));
}
return TCL_OK;
}
@@ -2155,7 +2152,7 @@ DictIncrCmd(
Tcl_DictObjPut(interp, dictPtr, objv[2], objv[3]);
}
} else {
- Tcl_DictObjPut(interp, dictPtr, objv[2], Tcl_NewIntObj(1));
+ Tcl_DictObjPut(interp, dictPtr, objv[2], Tcl_NewLongObj(1));
}
} else {
/*
@@ -2169,7 +2166,7 @@ DictIncrCmd(
if (objc == 4) {
code = TclIncrObj(interp, valuePtr, objv[3]);
} else {
- Tcl_Obj *incrPtr = Tcl_NewIntObj(1);
+ Tcl_Obj *incrPtr = Tcl_NewLongObj(1);
Tcl_IncrRefCount(incrPtr);
code = TclIncrObj(interp, valuePtr, incrPtr);
@@ -2914,8 +2911,8 @@ DictFilterCmd(
Tcl_WrongNumArgs(interp, 1, objv, "dictionary filterType ?arg ...?");
return TCL_ERROR;
}
- if (Tcl_GetIndexFromObj(interp, objv[2], filters, "filterType",
- 0, &index) != TCL_OK) {
+ if (Tcl_GetIndexFromObjStruct(interp, objv[2], filters,
+ sizeof(char *), "filterType", 0, &index) != TCL_OK) {
return TCL_ERROR;
}