From 26562de08390bae627d1602206683fae653f0c25 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Fri, 8 Jul 2016 06:56:17 +0000 Subject: Adapt hash-function and hash-table to allow hash-tables to grow >1Gb on 64-bit platforms. --- doc/Hash.3 | 4 +-- generic/tcl.h | 28 +++++++-------- generic/tclAssembly.c | 2 +- generic/tclDictObj.c | 2 +- generic/tclEnsemble.c | 2 +- generic/tclHash.c | 99 +++++++++++++++++++++++++++------------------------ generic/tclInt.h | 2 +- generic/tclLiteral.c | 8 ++--- generic/tclOOInt.h | 2 +- generic/tclObj.c | 12 +++---- generic/tclTest.c | 4 +-- generic/tclVar.c | 2 +- unix/dltest/pkgua.c | 2 +- 13 files changed, 87 insertions(+), 82 deletions(-) diff --git a/doc/Hash.3 b/doc/Hash.3 index 4dc3623..a7d644f 100644 --- a/doc/Hash.3 +++ b/doc/Hash.3 @@ -259,7 +259,7 @@ typedef struct Tcl_HashKeyType { .PP The \fIversion\fR member is the version of the table. If this structure is extended in future then the version can be used to distinguish between -different structures. It should be set to \fBTCL_HASH_KEY_TYPE_VERSION\fR. +different structures. It should be set to \fBTCL_HASH_KEY_TYPE_VERSION_2\fR. .PP The \fIflags\fR member is 0 or one or more of the following values OR'ed together: @@ -281,7 +281,7 @@ The \fIhashKeyProc\fR member contains the address of a function called to calculate a hash value for the key. .PP .CS -typedef unsigned int \fBTcl_HashKeyProc\fR( +typedef size_t \fBTcl_HashKeyProc\fR( Tcl_HashTable *\fItablePtr\fR, void *\fIkeyPtr\fR); .CE diff --git a/generic/tcl.h b/generic/tcl.h index aaef7c6..cf43ff0 100644 --- a/generic/tcl.h +++ b/generic/tcl.h @@ -940,7 +940,7 @@ typedef struct Tcl_HashKeyType Tcl_HashKeyType; typedef struct Tcl_HashTable Tcl_HashTable; typedef struct Tcl_HashEntry Tcl_HashEntry; -typedef unsigned (Tcl_HashKeyProc) (Tcl_HashTable *tablePtr, void *keyPtr); +typedef size_t (Tcl_HashKeyProc) (Tcl_HashTable *tablePtr, void *keyPtr); typedef int (Tcl_CompareHashKeysProc) (void *keyPtr, Tcl_HashEntry *hPtr); typedef Tcl_HashEntry * (Tcl_AllocHashEntryProc) (Tcl_HashTable *tablePtr, void *keyPtr); @@ -955,13 +955,11 @@ struct Tcl_HashEntry { Tcl_HashEntry *nextPtr; /* Pointer to next entry in this hash bucket, * or NULL for end of chain. */ Tcl_HashTable *tablePtr; /* Pointer to table containing entry. */ - void *hash; /* Hash value, stored as pointer to ensure - * that the offsets of the fields in this - * structure are not changed. */ + size_t hash; /* Hash value */ ClientData clientData; /* Application stores something here with * Tcl_SetHashValue. */ union { /* Key has one of these forms: */ - char *oneWordValue; /* One-word value for key. */ + const void *oneWordValue; /* One-word value for key. */ Tcl_Obj *objPtr; /* Tcl_Obj * key value. */ int words[1]; /* Multiple integer words for key. The actual * size will be as large as necessary for this @@ -994,6 +992,8 @@ struct Tcl_HashEntry { */ #define TCL_HASH_KEY_TYPE_VERSION 1 +#define TCL_HASH_KEY_TYPE_VERSION_2 2 + struct Tcl_HashKeyType { int version; /* Version of the table. If this structure is * extended in future then the version can be @@ -1046,23 +1046,23 @@ struct Tcl_HashTable { Tcl_HashEntry *staticBuckets[TCL_SMALL_HASH_TABLE]; /* Bucket array used for small tables (to * avoid mallocs and frees). */ - int numBuckets; /* Total number of buckets allocated at + size_t numBuckets; /* Total number of buckets allocated at * **bucketPtr. */ - int numEntries; /* Total number of entries present in + size_t numEntries; /* Total number of entries present in * table. */ - int rebuildSize; /* Enlarge table when numEntries gets to be + size_t rebuildSize; /* Enlarge table when numEntries gets to be * this large. */ + size_t mask; /* Mask value used in hashing function. */ int downShift; /* Shift count used in hashing function. * Designed to use high-order bits of * randomized keys. */ - int mask; /* Mask value used in hashing function. */ int keyType; /* Type of keys used in this table. It's * either TCL_CUSTOM_KEYS, TCL_STRING_KEYS, * TCL_ONE_WORD_KEYS, or an integer giving the * number of ints that is the size of the * key. */ - Tcl_HashEntry *(*findProc) (Tcl_HashTable *tablePtr, const char *key); - Tcl_HashEntry *(*createProc) (Tcl_HashTable *tablePtr, const char *key, + Tcl_HashEntry *(*findProc) (Tcl_HashTable *tablePtr, const void *key); + Tcl_HashEntry *(*createProc) (Tcl_HashTable *tablePtr, const void *key, int *newPtr); const Tcl_HashKeyType *typePtr; /* Type of the keys used in the @@ -1076,7 +1076,7 @@ struct Tcl_HashTable { typedef struct Tcl_HashSearch { Tcl_HashTable *tablePtr; /* Table being searched. */ - int nextIndex; /* Index of next bucket to be enumerated after + size_t nextIndex; /* Index of next bucket to be enumerated after * present one. */ Tcl_HashEntry *nextEntryPtr;/* Next entry to be enumerated in the current * bucket. */ @@ -2360,9 +2360,9 @@ TCLAPI void Tcl_GetMemoryInfo(Tcl_DString *dsPtr); */ #define Tcl_FindHashEntry(tablePtr, key) \ - (*((tablePtr)->findProc))(tablePtr, (const char *)(key)) + (*((tablePtr)->findProc))(tablePtr, key) #define Tcl_CreateHashEntry(tablePtr, key, newPtr) \ - (*((tablePtr)->createProc))(tablePtr, (const char *)(key), newPtr) + (*((tablePtr)->createProc))(tablePtr, key, newPtr) /* *---------------------------------------------------------------------------- diff --git a/generic/tclAssembly.c b/generic/tclAssembly.c index 8dd23a0..2116f2b 100644 --- a/generic/tclAssembly.c +++ b/generic/tclAssembly.c @@ -2884,7 +2884,7 @@ CheckJumpTableLabels( valEntryPtr = Tcl_FindHashEntry(&assemEnvPtr->labelHash, Tcl_GetString(symbolObj)); DEBUG_PRINT(" %s -> %s (%d)\n", - (char*) Tcl_GetHashKey(symHash, symEntryPtr), + Tcl_GetHashKey(symHash, symEntryPtr), Tcl_GetString(symbolObj), (valEntryPtr != NULL)); if (valEntryPtr == NULL) { ReportUndefinedLabel(assemEnvPtr, bbPtr, symbolObj); diff --git a/generic/tclDictObj.c b/generic/tclDictObj.c index c172df0..e37dcb6 100644 --- a/generic/tclDictObj.c +++ b/generic/tclDictObj.c @@ -179,7 +179,7 @@ const Tcl_ObjType tclDictType = { */ static const Tcl_HashKeyType chainHashType = { - TCL_HASH_KEY_TYPE_VERSION, + TCL_HASH_KEY_TYPE_VERSION_2, 0, TclHashObjKey, TclCompareObjKeys, diff --git a/generic/tclEnsemble.c b/generic/tclEnsemble.c index a829b59..8f31318 100644 --- a/generic/tclEnsemble.c +++ b/generic/tclEnsemble.c @@ -1931,7 +1931,7 @@ NsEnsembleImplementationCmdNR( if (ensemblePtr->subcommandTable.numEntries == 1) { Tcl_AppendToObj(errorObj, ensemblePtr->subcommandArrayPtr[0], -1); } else { - int i; + size_t i; for (i=0 ; isubcommandTable.numEntries-1 ; i++) { Tcl_AppendToObj(errorObj, ensemblePtr->subcommandArrayPtr[i], -1); diff --git a/generic/tclHash.c b/generic/tclHash.c index 27919c5..f0d71d3 100644 --- a/generic/tclHash.c +++ b/generic/tclHash.c @@ -36,7 +36,7 @@ static Tcl_HashEntry * AllocArrayEntry(Tcl_HashTable *tablePtr, void *keyPtr); static int CompareArrayKeys(void *keyPtr, Tcl_HashEntry *hPtr); -static unsigned int HashArrayKey(Tcl_HashTable *tablePtr, void *keyPtr); +static size_t HashArrayKey(Tcl_HashTable *tablePtr, void *keyPtr); /* * Prototypes for the one word hash key methods. Not actually declared because @@ -48,7 +48,7 @@ static unsigned int HashArrayKey(Tcl_HashTable *tablePtr, void *keyPtr); static Tcl_HashEntry * AllocOneWordEntry(Tcl_HashTable *tablePtr, void *keyPtr); static int CompareOneWordKeys(void *keyPtr, Tcl_HashEntry *hPtr); -static unsigned int HashOneWordKey(Tcl_HashTable *tablePtr, void *keyPtr); +static size_t HashOneWordKey(Tcl_HashTable *tablePtr, const void *keyPtr); #endif /* @@ -58,22 +58,22 @@ static unsigned int HashOneWordKey(Tcl_HashTable *tablePtr, void *keyPtr); static Tcl_HashEntry * AllocStringEntry(Tcl_HashTable *tablePtr, void *keyPtr); static int CompareStringKeys(void *keyPtr, Tcl_HashEntry *hPtr); -static unsigned int HashStringKey(Tcl_HashTable *tablePtr, void *keyPtr); +static size_t HashStringKey(Tcl_HashTable *tablePtr, void *keyPtr); /* * Function prototypes for static functions in this file: */ -static Tcl_HashEntry * BogusFind(Tcl_HashTable *tablePtr, const char *key); -static Tcl_HashEntry * BogusCreate(Tcl_HashTable *tablePtr, const char *key, +static Tcl_HashEntry * BogusFind(Tcl_HashTable *tablePtr, const void *key); +static Tcl_HashEntry * BogusCreate(Tcl_HashTable *tablePtr, const void *key, int *newPtr); -static Tcl_HashEntry * CreateHashEntry(Tcl_HashTable *tablePtr, const char *key, +static Tcl_HashEntry * CreateHashEntry(Tcl_HashTable *tablePtr, const void *key, int *newPtr); -static Tcl_HashEntry * FindHashEntry(Tcl_HashTable *tablePtr, const char *key); +static Tcl_HashEntry * FindHashEntry(Tcl_HashTable *tablePtr, const void *key); static void RebuildTable(Tcl_HashTable *tablePtr); const Tcl_HashKeyType tclArrayHashKeyType = { - TCL_HASH_KEY_TYPE_VERSION, /* version */ + TCL_HASH_KEY_TYPE_VERSION_2, /* version */ TCL_HASH_KEY_RANDOMIZE_HASH, /* flags */ HashArrayKey, /* hashKeyProc */ CompareArrayKeys, /* compareKeysProc */ @@ -82,7 +82,7 @@ const Tcl_HashKeyType tclArrayHashKeyType = { }; const Tcl_HashKeyType tclOneWordHashKeyType = { - TCL_HASH_KEY_TYPE_VERSION, /* version */ + TCL_HASH_KEY_TYPE_VERSION_2, /* version */ 0, /* flags */ NULL, /* HashOneWordKey, */ /* hashProc */ NULL, /* CompareOneWordKey, */ /* compareProc */ @@ -91,7 +91,7 @@ const Tcl_HashKeyType tclOneWordHashKeyType = { }; const Tcl_HashKeyType tclStringHashKeyType = { - TCL_HASH_KEY_TYPE_VERSION, /* version */ + TCL_HASH_KEY_TYPE_VERSION_2, /* version */ 0, /* flags */ HashStringKey, /* hashKeyProc */ CompareStringKeys, /* compareKeysProc */ @@ -206,7 +206,7 @@ Tcl_InitCustomHashTable( static Tcl_HashEntry * FindHashEntry( Tcl_HashTable *tablePtr, /* Table in which to lookup entry. */ - const char *key) /* Key to use to find matching entry. */ + const void *key) /* Key to use to find matching entry. */ { return CreateHashEntry(tablePtr, key, NULL); } @@ -236,15 +236,15 @@ FindHashEntry( static Tcl_HashEntry * CreateHashEntry( Tcl_HashTable *tablePtr, /* Table in which to lookup entry. */ - const char *key, /* Key to use to find or create matching + const void *key, /* Key to use to find or create matching * entry. */ int *newPtr) /* Store info here telling whether a new entry * was created. */ { register Tcl_HashEntry *hPtr; const Tcl_HashKeyType *typePtr; - unsigned int hash; - int index; + size_t hash; + size_t index; if (tablePtr->keyType == TCL_STRING_KEYS) { typePtr = &tclStringHashKeyType; @@ -258,14 +258,19 @@ CreateHashEntry( } if (typePtr->hashKeyProc) { - hash = typePtr->hashKeyProc(tablePtr, (void *) key); + if (typePtr->version == TCL_HASH_KEY_TYPE_VERSION) { + hash = ((unsigned int (*)(Tcl_HashTable *, void *)) + typePtr->hashKeyProc)(tablePtr, (void *) key); + } else { + hash = typePtr->hashKeyProc(tablePtr, (void *) key); + } if (typePtr->flags & TCL_HASH_KEY_RANDOMIZE_HASH) { index = RANDOM_INDEX(tablePtr, hash); } else { index = hash & tablePtr->mask; } } else { - hash = PTR2UINT(key); + hash = (size_t)(key); index = RANDOM_INDEX(tablePtr, hash); } @@ -278,7 +283,7 @@ CreateHashEntry( for (hPtr = tablePtr->buckets[index]; hPtr != NULL; hPtr = hPtr->nextPtr) { - if (hash != PTR2UINT(hPtr->hash)) { + if (hash != hPtr->hash) { continue; } if (((void *) key == hPtr) || compareKeysProc((void *) key, hPtr)) { @@ -291,7 +296,7 @@ CreateHashEntry( } else { for (hPtr = tablePtr->buckets[index]; hPtr != NULL; hPtr = hPtr->nextPtr) { - if (hash != PTR2UINT(hPtr->hash)) { + if (hash != hPtr->hash) { continue; } if (key == hPtr->key.oneWordValue) { @@ -316,12 +321,12 @@ CreateHashEntry( hPtr = typePtr->allocEntryProc(tablePtr, (void *) key); } else { hPtr = ckalloc(sizeof(Tcl_HashEntry)); - hPtr->key.oneWordValue = (char *) key; + hPtr->key.oneWordValue = key; hPtr->clientData = 0; } hPtr->tablePtr = tablePtr; - hPtr->hash = UINT2PTR(hash); + hPtr->hash = hash; hPtr->nextPtr = tablePtr->buckets[index]; tablePtr->buckets[index] = hPtr; tablePtr->numEntries++; @@ -363,7 +368,7 @@ Tcl_DeleteHashEntry( const Tcl_HashKeyType *typePtr; Tcl_HashTable *tablePtr; Tcl_HashEntry **bucketPtr; - int index; + size_t index; tablePtr = entryPtr->tablePtr; @@ -380,9 +385,9 @@ Tcl_DeleteHashEntry( if (typePtr->hashKeyProc == NULL || typePtr->flags & TCL_HASH_KEY_RANDOMIZE_HASH) { - index = RANDOM_INDEX(tablePtr, PTR2INT(entryPtr->hash)); + index = RANDOM_INDEX(tablePtr, entryPtr->hash); } else { - index = PTR2UINT(entryPtr->hash) & tablePtr->mask; + index = entryPtr->hash & tablePtr->mask; } bucketPtr = &tablePtr->buckets[index]; @@ -432,7 +437,7 @@ Tcl_DeleteHashTable( { register Tcl_HashEntry *hPtr, *nextPtr; const Tcl_HashKeyType *typePtr; - int i; + size_t i; if (tablePtr->keyType == TCL_STRING_KEYS) { typePtr = &tclStringHashKeyType; @@ -581,7 +586,7 @@ Tcl_HashStats( Tcl_HashTable *tablePtr) /* Table for which to produce stats. */ { #define NUM_COUNTERS 10 - int count[NUM_COUNTERS], overflow, i, j; + size_t count[NUM_COUNTERS], overflow, i, j; double average, tmp; register Tcl_HashEntry *hPtr; char *result, *p; @@ -616,16 +621,16 @@ Tcl_HashStats( */ result = ckalloc((NUM_COUNTERS * 60) + 300); - sprintf(result, "%d entries in table, %d buckets\n", - tablePtr->numEntries, tablePtr->numBuckets); + sprintf(result, "%" TCL_LL_MODIFIER "d entries in table, %" TCL_LL_MODIFIER "d buckets\n", + (Tcl_WideInt)tablePtr->numEntries, (Tcl_WideInt)tablePtr->numBuckets); p = result + strlen(result); for (i = 0; i < NUM_COUNTERS; i++) { - sprintf(p, "number of buckets with %d entries: %d\n", - i, count[i]); + sprintf(p, "number of buckets with %d entries: %" TCL_LL_MODIFIER "d\n", + (int)i, (Tcl_WideInt)count[i]); p += strlen(p); } - sprintf(p, "number of buckets with %d or more entries: %d\n", - NUM_COUNTERS, overflow); + sprintf(p, "number of buckets with %d or more entries: %" TCL_LL_MODIFIER "d\n", + NUM_COUNTERS, (Tcl_WideInt)overflow); p += strlen(p); sprintf(p, "average search distance for entry: %.1f", average); return result; @@ -656,7 +661,7 @@ AllocArrayEntry( register int *iPtr1, *iPtr2; Tcl_HashEntry *hPtr; int count; - unsigned int size; + size_t size; count = tablePtr->keyType; @@ -731,13 +736,13 @@ CompareArrayKeys( *---------------------------------------------------------------------- */ -static unsigned int +static size_t HashArrayKey( Tcl_HashTable *tablePtr, /* Hash table. */ void *keyPtr) /* Key from which to compute hash value. */ { register const int *array = (const int *) keyPtr; - register unsigned int result; + register size_t result; int count; for (result = 0, count = tablePtr->keyType; count > 0; @@ -768,9 +773,9 @@ AllocStringEntry( Tcl_HashTable *tablePtr, /* Hash table. */ void *keyPtr) /* Key to store in the hash table entry. */ { - const char *string = (const char *) keyPtr; + const char *string = keyPtr; Tcl_HashEntry *hPtr; - unsigned int size, allocsize; + size_t size, allocsize; allocsize = size = strlen(string) + 1; if (size < sizeof(hPtr->key)) { @@ -804,8 +809,8 @@ CompareStringKeys( void *keyPtr, /* New key to compare. */ Tcl_HashEntry *hPtr) /* Existing key to compare. */ { - register const char *p1 = (const char *) keyPtr; - register const char *p2 = (const char *) hPtr->key.string; + register const char *p1 = keyPtr; + register const char *p2 = hPtr->key.string; return !strcmp(p1, p2); } @@ -827,13 +832,13 @@ CompareStringKeys( *---------------------------------------------------------------------- */ -static unsigned +static size_t HashStringKey( Tcl_HashTable *tablePtr, /* Hash table. */ void *keyPtr) /* Key from which to compute hash value. */ { register const char *string = keyPtr; - register unsigned int result; + register size_t result; register char c; /* @@ -897,7 +902,7 @@ HashStringKey( static Tcl_HashEntry * BogusFind( Tcl_HashTable *tablePtr, /* Table in which to lookup entry. */ - const char *key) /* Key to use to find matching entry. */ + const void *key) /* Key to use to find matching entry. */ { Tcl_Panic("called %s on deleted table", "Tcl_FindHashEntry"); return NULL; @@ -924,7 +929,7 @@ BogusFind( static Tcl_HashEntry * BogusCreate( Tcl_HashTable *tablePtr, /* Table in which to lookup entry. */ - const char *key, /* Key to use to find or create matching + const void *key, /* Key to use to find or create matching * entry. */ int *newPtr) /* Store info here telling whether a new entry * was created. */ @@ -955,7 +960,7 @@ static void RebuildTable( register Tcl_HashTable *tablePtr) /* Table to enlarge. */ { - int oldSize, count, index; + size_t oldSize, count, index; Tcl_HashEntry **oldBuckets; register Tcl_HashEntry **oldChainPtr, **newChainPtr; register Tcl_HashEntry *hPtr; @@ -982,8 +987,8 @@ RebuildTable( tablePtr->numBuckets *= 4; if (typePtr->flags & TCL_HASH_KEY_SYSTEM_HASH) { - tablePtr->buckets = (Tcl_HashEntry **) TclpSysAlloc((unsigned) - (tablePtr->numBuckets * sizeof(Tcl_HashEntry *)), 0); + tablePtr->buckets = (Tcl_HashEntry **) TclpSysAlloc( + tablePtr->numBuckets * sizeof(Tcl_HashEntry *), 0); } else { tablePtr->buckets = ckalloc(tablePtr->numBuckets * sizeof(Tcl_HashEntry *)); @@ -1005,9 +1010,9 @@ RebuildTable( *oldChainPtr = hPtr->nextPtr; if (typePtr->hashKeyProc == NULL || typePtr->flags & TCL_HASH_KEY_RANDOMIZE_HASH) { - index = RANDOM_INDEX(tablePtr, PTR2INT(hPtr->hash)); + index = RANDOM_INDEX(tablePtr, hPtr->hash); } else { - index = PTR2UINT(hPtr->hash) & tablePtr->mask; + index = hPtr->hash & tablePtr->mask; } hPtr->nextPtr = tablePtr->buckets[index]; tablePtr->buckets[index] = hPtr; diff --git a/generic/tclInt.h b/generic/tclInt.h index 9b01fd8..762943b 100644 --- a/generic/tclInt.h +++ b/generic/tclInt.h @@ -3898,7 +3898,7 @@ MODULE_SCOPE int TclObjCallVarTraces(Interp *iPtr, Var *arrayPtr, MODULE_SCOPE int TclCompareObjKeys(void *keyPtr, Tcl_HashEntry *hPtr); MODULE_SCOPE void TclFreeObjEntry(Tcl_HashEntry *hPtr); -MODULE_SCOPE unsigned TclHashObjKey(Tcl_HashTable *tablePtr, void *keyPtr); +MODULE_SCOPE size_t TclHashObjKey(Tcl_HashTable *tablePtr, void *keyPtr); MODULE_SCOPE int TclFullFinalizationRequested(void); diff --git a/generic/tclLiteral.c b/generic/tclLiteral.c index 03200ca..306e426 100644 --- a/generic/tclLiteral.c +++ b/generic/tclLiteral.c @@ -31,7 +31,7 @@ static int AddLocalLiteralEntry(CompileEnv *envPtr, Tcl_Obj *objPtr, int localHash); static void ExpandLocalLiteralArray(CompileEnv *envPtr); -static unsigned HashString(const char *string, int length); +static size_t HashString(const char *string, size_t length); #ifdef TCL_COMPILE_DEBUG static LiteralEntry * LookupLiteralEntry(Tcl_Interp *interp, Tcl_Obj *objPtr); @@ -864,12 +864,12 @@ TclReleaseLiteral( *---------------------------------------------------------------------- */ -static unsigned +static size_t HashString( register const char *string, /* String for which to compute hash value. */ - int length) /* Number of bytes in the string. */ + size_t length) /* Number of bytes in the string. */ { - register unsigned int result = 0; + register size_t result = 0; /* * I tried a zillion different hash functions and asked many other people diff --git a/generic/tclOOInt.h b/generic/tclOOInt.h index b75ffdb..cda1826 100644 --- a/generic/tclOOInt.h +++ b/generic/tclOOInt.h @@ -563,7 +563,7 @@ MODULE_SCOPE void TclOOSetupVariableResolver(Tcl_Namespace *nsPtr); Tcl_HashEntry *hPtr;Tcl_HashSearch search #define FOREACH_HASH(key,val,tablePtr) \ for(hPtr=Tcl_FirstHashEntry((tablePtr),&search); hPtr!=NULL ? \ - ((key)=(void *)Tcl_GetHashKey((tablePtr),hPtr),\ + ((key)=Tcl_GetHashKey((tablePtr),hPtr),\ (val)=Tcl_GetHashValue(hPtr),1):0; hPtr=Tcl_NextHashEntry(&search)) #define FOREACH_HASH_VALUE(val,tablePtr) \ for(hPtr=Tcl_FirstHashEntry((tablePtr),&search); hPtr!=NULL ? \ diff --git a/generic/tclObj.c b/generic/tclObj.c index 4640725..dde9503 100644 --- a/generic/tclObj.c +++ b/generic/tclObj.c @@ -293,7 +293,7 @@ const Tcl_ObjType tclBignumType = { */ const Tcl_HashKeyType tclObjHashKeyType = { - TCL_HASH_KEY_TYPE_VERSION, /* version */ + TCL_HASH_KEY_TYPE_VERSION_2, /* version */ 0, /* flags */ TclHashObjKey, /* hashKeyProc */ TclCompareObjKeys, /* compareKeysProc */ @@ -4049,15 +4049,15 @@ TclFreeObjEntry( *---------------------------------------------------------------------- */ -unsigned int +size_t TclHashObjKey( Tcl_HashTable *tablePtr, /* Hash table. */ void *keyPtr) /* Key from which to compute hash value. */ { - Tcl_Obj *objPtr = keyPtr; - int length; - const char *string = TclGetStringFromObj(objPtr, &length); - unsigned int result = 0; + Tcl_Obj *objPtr = (Tcl_Obj *)keyPtr; + const char *string = TclGetString(objPtr); + size_t length = objPtr->length; + size_t result = 0; /* * I tried a zillion different hash functions and asked many other people diff --git a/generic/tclTest.c b/generic/tclTest.c index f2a948a..05383bb 100644 --- a/generic/tclTest.c +++ b/generic/tclTest.c @@ -6611,7 +6611,7 @@ TestHashSystemHashCmd( Tcl_Obj *const objv[]) { static const Tcl_HashKeyType hkType = { - TCL_HASH_KEY_TYPE_VERSION, TCL_HASH_KEY_SYSTEM_HASH, + TCL_HASH_KEY_TYPE_VERSION_2, TCL_HASH_KEY_SYSTEM_HASH, NULL, NULL, NULL, NULL }; Tcl_HashTable hash; @@ -6641,7 +6641,7 @@ TestHashSystemHashCmd( Tcl_SetHashValue(hPtr, INT2PTR(i+42)); } - if (hash.numEntries != limit) { + if (hash.numEntries != (size_t)limit) { Tcl_AppendResult(interp, "unexpected maximal size", NULL); Tcl_DeleteHashTable(&hash); return TCL_ERROR; diff --git a/generic/tclVar.c b/generic/tclVar.c index 87771b2..3031a8a 100644 --- a/generic/tclVar.c +++ b/generic/tclVar.c @@ -29,7 +29,7 @@ static void FreeVarEntry(Tcl_HashEntry *hPtr); static int CompareVarKeys(void *keyPtr, Tcl_HashEntry *hPtr); static const Tcl_HashKeyType tclVarHashKeyType = { - TCL_HASH_KEY_TYPE_VERSION, /* version */ + TCL_HASH_KEY_TYPE_VERSION_2, /* version */ 0, /* flags */ TclHashObjKey, /* hashKeyProc */ CompareVarKeys, /* compareKeysProc */ diff --git a/unix/dltest/pkgua.c b/unix/dltest/pkgua.c index ea5fde5..bb2eec1 100644 --- a/unix/dltest/pkgua.c +++ b/unix/dltest/pkgua.c @@ -69,7 +69,7 @@ PkguaInterpToTokens( int newEntry; Tcl_Command *cmdTokens; Tcl_HashEntry *entryPtr = - Tcl_CreateHashEntry(&interpTokenMap, (char *) interp, &newEntry); + Tcl_CreateHashEntry(&interpTokenMap, interp, &newEntry); if (newEntry) { cmdTokens = (Tcl_Command *) -- cgit v0.12