Update to 8.5.19
This commit is contained in:
@@ -153,7 +153,7 @@ TclDeleteLiteralTable(
|
||||
* Find, or if necessary create, an object in the interpreter's literal
|
||||
* table that has a string representation matching the argument
|
||||
* string. If nsPtr!=NULL then only literals stored for the namespace are
|
||||
* considered.
|
||||
* considered.
|
||||
*
|
||||
* Results:
|
||||
* The literal object. If it was created in this call *newPtr is set to
|
||||
@@ -161,7 +161,7 @@ TclDeleteLiteralTable(
|
||||
*
|
||||
* Side effects:
|
||||
* Increments the ref count of the global LiteralEntry since the caller
|
||||
* now holds a reference.
|
||||
* now holds a reference.
|
||||
* If LITERAL_ON_HEAP is set in flags, this function is given ownership
|
||||
* of the string: if an object is created then its string representation
|
||||
* is set directly from string, otherwise the string is freed. Typically,
|
||||
@@ -186,7 +186,7 @@ TclCreateLiteral(
|
||||
LiteralEntry *globalPtr;
|
||||
int globalHash;
|
||||
Tcl_Obj *objPtr;
|
||||
|
||||
|
||||
/*
|
||||
* Is it in the interpreter's global literal table?
|
||||
*/
|
||||
@@ -682,16 +682,22 @@ ExpandLocalLiteralArray(
|
||||
LiteralEntry *currArrayPtr = envPtr->literalArrayPtr;
|
||||
LiteralEntry *newArrayPtr;
|
||||
int i;
|
||||
unsigned int newSize = (currBytes <= UINT_MAX / 2) ? 2*currBytes : UINT_MAX;
|
||||
|
||||
if (currBytes == newSize) {
|
||||
Tcl_Panic("max size of Tcl literal array (%d literals) exceeded",
|
||||
currElems);
|
||||
}
|
||||
|
||||
if (envPtr->mallocedLiteralArray) {
|
||||
newArrayPtr = (LiteralEntry *) ckrealloc(
|
||||
(char *)currArrayPtr, 2 * currBytes);
|
||||
(char *)currArrayPtr, newSize);
|
||||
} else {
|
||||
/*
|
||||
* envPtr->literalArrayPtr isn't a ckalloc'd pointer, so we must
|
||||
* code a ckrealloc equivalent for ourselves
|
||||
*/
|
||||
newArrayPtr = (LiteralEntry *) ckalloc(2 * currBytes);
|
||||
newArrayPtr = (LiteralEntry *) ckalloc(newSize);
|
||||
memcpy(newArrayPtr, currArrayPtr, currBytes);
|
||||
envPtr->mallocedLiteralArray = 1;
|
||||
}
|
||||
@@ -703,7 +709,7 @@ ExpandLocalLiteralArray(
|
||||
if (currArrayPtr != newArrayPtr) {
|
||||
for (i=0 ; i<currElems ; i++) {
|
||||
if (newArrayPtr[i].nextPtr != NULL) {
|
||||
newArrayPtr[i].nextPtr = newArrayPtr
|
||||
newArrayPtr[i].nextPtr = newArrayPtr
|
||||
+ (newArrayPtr[i].nextPtr - currArrayPtr);
|
||||
}
|
||||
}
|
||||
@@ -716,7 +722,7 @@ ExpandLocalLiteralArray(
|
||||
}
|
||||
|
||||
envPtr->literalArrayPtr = newArrayPtr;
|
||||
envPtr->literalArrayEnd = (2 * currElems);
|
||||
envPtr->literalArrayEnd = newSize / sizeof(LiteralEntry);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -876,7 +882,8 @@ RebuildLiteralTable(
|
||||
register LiteralEntry *entryPtr;
|
||||
LiteralEntry **bucketPtr;
|
||||
char *bytes;
|
||||
int oldSize, count, index, length;
|
||||
unsigned int oldSize;
|
||||
int count, index, length;
|
||||
|
||||
oldSize = tablePtr->numBuckets;
|
||||
oldBuckets = tablePtr->buckets;
|
||||
@@ -886,6 +893,16 @@ RebuildLiteralTable(
|
||||
* constants for new array size.
|
||||
*/
|
||||
|
||||
if (oldSize > UINT_MAX/(4 * sizeof(LiteralEntry *))) {
|
||||
/*
|
||||
* Memory allocator limitations will not let us create the
|
||||
* next larger table size. Best option is to limp along
|
||||
* with what we have.
|
||||
*/
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
tablePtr->numBuckets *= 4;
|
||||
tablePtr->buckets = (LiteralEntry **) ckalloc((unsigned)
|
||||
(tablePtr->numBuckets * sizeof(LiteralEntry *)));
|
||||
|
||||
Reference in New Issue
Block a user