diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2017-11-15 08:55:18 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2017-11-15 08:55:18 (GMT) |
commit | e3439b6af28680828231cfcf081ebb618ac1740f (patch) | |
tree | 70afb2ca078b69006eee79db38912879100be06b /generic/tclDictObj.c | |
parent | 9f6573581348d2a8ceb4647ad9781d35644aee8b (diff) | |
parent | 59ebc49f0f9163be7bcbd33b23e6eae865540ab4 (diff) | |
download | tcl-e3439b6af28680828231cfcf081ebb618ac1740f.zip tcl-e3439b6af28680828231cfcf081ebb618ac1740f.tar.gz tcl-e3439b6af28680828231cfcf081ebb618ac1740f.tar.bz2 |
Change signature of (internal) TclScanElement() function. This saves memory allocation and the possibility for panic's in dict and list handling, requiring 1/4 of memory for internal allocation of temporary storage. No change to external API.
Diffstat (limited to 'generic/tclDictObj.c')
-rw-r--r-- | generic/tclDictObj.c | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/generic/tclDictObj.c b/generic/tclDictObj.c index b1962e6..3b983e3 100644 --- a/generic/tclDictObj.c +++ b/generic/tclDictObj.c @@ -487,15 +487,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 = DICT(dictPtr); 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 @@ -517,10 +516,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) { /* |