diff options
Diffstat (limited to 'generic')
| -rw-r--r-- | generic/tclClockFmt.c | 23 | ||||
| -rw-r--r-- | generic/tclHash.c | 33 | ||||
| -rw-r--r-- | generic/tclInt.h | 2 |
3 files changed, 30 insertions, 28 deletions
diff --git a/generic/tclClockFmt.c b/generic/tclClockFmt.c index fead7fd..0dfc9bb 100644 --- a/generic/tclClockFmt.c +++ b/generic/tclClockFmt.c @@ -22,20 +22,28 @@ static void ClockFmtObj_DupInternalRep(Tcl_Obj *srcPtr, Tcl_Obj *copyPtr); static void ClockFmtObj_FreeInternalRep(Tcl_Obj *objPtr); static int ClockFmtObj_SetFromAny(Tcl_Interp *, Tcl_Obj *objPtr); static void ClockFmtObj_UpdateString(Tcl_Obj *objPtr); +static Tcl_HashEntry * ClockFmtScnStorageAllocProc(Tcl_HashTable *, void *keyPtr); +static void ClockFmtScnStorageFreeProc(Tcl_HashEntry *hPtr); +static void ClockFmtScnStorageDelete(ClockFmtScnStorage *fss); TCL_DECLARE_MUTEX(ClockFmtMutex); /* Serializes access to common format list. */ -static void ClockFmtScnStorageDelete(ClockFmtScnStorage *fss); - #ifndef TCL_CLOCK_FULL_COMPAT #define TCL_CLOCK_FULL_COMPAT 1 #endif /* - * Derivation of tclStringHashKeyType with another allocEntryProc + * Derivation of tclStringHashKeyType with extra memory management trickery. */ -static Tcl_HashKeyType ClockFmtScnStorageHashKeyType; +static const Tcl_HashKeyType ClockFmtScnStorageHashKeyType = { + TCL_HASH_KEY_TYPE_VERSION, /* version */ + 0, /* flags */ + TclHashStringKey, /* hashKeyProc */ + TclCompareStringKeys, /* compareKeysProc */ + ClockFmtScnStorageAllocProc, /* allocEntryProc */ + ClockFmtScnStorageFreeProc /* freeEntryProc */ +}; #define IntFieldAt(info, offset) \ ((int *) (((char *) (info)) + (offset))) @@ -543,7 +551,7 @@ FmtScn4HashEntry( static Tcl_HashEntry * ClockFmtScnStorageAllocProc( - TCL_UNUSED(Tcl_HashTable *), /* Hash table. */ + TCL_UNUSED(Tcl_HashTable *),/* Hash table. */ void *keyPtr) /* Key to store in the hash table entry. */ { ClockFmtScnStorage *fss; @@ -825,11 +833,6 @@ FindOrCreateFmtScnStorage( /* if not yet initialized */ if (!initialized) { - /* initialize type */ - memcpy(&ClockFmtScnStorageHashKeyType, &tclStringHashKeyType, sizeof(tclStringHashKeyType)); - ClockFmtScnStorageHashKeyType.allocEntryProc = ClockFmtScnStorageAllocProc; - ClockFmtScnStorageHashKeyType.freeEntryProc = ClockFmtScnStorageFreeProc; - /* initialize hash table */ Tcl_InitCustomHashTable(&FmtScnHashTable, TCL_CUSTOM_TYPE_KEYS, &ClockFmtScnStorageHashKeyType); diff --git a/generic/tclHash.c b/generic/tclHash.c index 89807e2..9bdb079 100644 --- a/generic/tclHash.c +++ b/generic/tclHash.c @@ -44,8 +44,6 @@ static size_t HashArrayKey(Tcl_HashTable *tablePtr, void *keyPtr); static Tcl_HashEntry * AllocStringEntry(Tcl_HashTable *tablePtr, void *keyPtr); -static int CompareStringKeys(void *keyPtr, Tcl_HashEntry *hPtr); -static size_t HashStringKey(Tcl_HashTable *tablePtr, void *keyPtr); /* * Function prototypes for static functions in this file: @@ -80,8 +78,8 @@ const Tcl_HashKeyType tclOneWordHashKeyType = { const Tcl_HashKeyType tclStringHashKeyType = { TCL_HASH_KEY_TYPE_VERSION, /* version */ 0, /* flags */ - HashStringKey, /* hashKeyProc */ - CompareStringKeys, /* compareKeysProc */ + TclHashStringKey, /* hashKeyProc */ + TclCompareStringKeys, /* compareKeysProc */ AllocStringEntry, /* allocEntryProc */ NULL /* freeEntryProc */ }; @@ -556,8 +554,7 @@ Tcl_FirstHashEntry( Tcl_HashEntry * Tcl_NextHashEntry( - Tcl_HashSearch *searchPtr) - /* Place to store information about progress + Tcl_HashSearch *searchPtr) /* Place to store information about progress * through the table. Must have been * initialized by calling * Tcl_FirstHashEntry. */ @@ -671,7 +668,7 @@ Tcl_HashStats( static Tcl_HashEntry * AllocArrayEntry( Tcl_HashTable *tablePtr, /* Hash table. */ - void *keyPtr) /* Key to store in the hash table entry. */ + void *keyPtr) /* Key to store in the hash table entry. */ { Tcl_HashEntry *hPtr; size_t count = tablePtr->keyType * sizeof(int); @@ -707,7 +704,7 @@ AllocArrayEntry( static int CompareArrayKeys( - void *keyPtr, /* New key to compare. */ + void *keyPtr, /* New key to compare. */ Tcl_HashEntry *hPtr) /* Existing key to compare. */ { size_t count = hPtr->tablePtr->keyType * sizeof(int); @@ -736,7 +733,7 @@ CompareArrayKeys( static size_t HashArrayKey( Tcl_HashTable *tablePtr, /* Hash table. */ - void *keyPtr) /* Key from which to compute hash value. */ + void *keyPtr) /* Key from which to compute hash value. */ { const int *array = (const int *) keyPtr; size_t result; @@ -768,7 +765,7 @@ HashArrayKey( static Tcl_HashEntry * AllocStringEntry( TCL_UNUSED(Tcl_HashTable *), - void *keyPtr) /* Key to store in the hash table entry. */ + void *keyPtr) /* Key to store in the hash table entry. */ { const char *string = (const char *) keyPtr; Tcl_HashEntry *hPtr; @@ -788,7 +785,7 @@ AllocStringEntry( /* *---------------------------------------------------------------------- * - * CompareStringKeys -- + * TclCompareStringKeys -- * * Compares two string keys. * @@ -802,9 +799,9 @@ AllocStringEntry( *---------------------------------------------------------------------- */ -static int -CompareStringKeys( - void *keyPtr, /* New key to compare. */ +int +TclCompareStringKeys( + void *keyPtr, /* New key to compare. */ Tcl_HashEntry *hPtr) /* Existing key to compare. */ { return !strcmp((char *)keyPtr, hPtr->key.string); @@ -813,7 +810,7 @@ CompareStringKeys( /* *---------------------------------------------------------------------- * - * HashStringKey -- + * TclHashStringKey -- * * Compute a one-word summary of a text string, which can be used to * generate a hash index. @@ -827,10 +824,10 @@ CompareStringKeys( *---------------------------------------------------------------------- */ -static size_t -HashStringKey( +size_t +TclHashStringKey( TCL_UNUSED(Tcl_HashTable *), - void *keyPtr) /* Key from which to compute hash value. */ + void *keyPtr) /* Key from which to compute hash value. */ { const char *string = (const char *)keyPtr; size_t result; diff --git a/generic/tclInt.h b/generic/tclInt.h index c9ff923..70bc4b8 100644 --- a/generic/tclInt.h +++ b/generic/tclInt.h @@ -3405,6 +3405,8 @@ MODULE_SCOPE int TclGetLoadedLibraries(Tcl_Interp *interp, const char *packageName); MODULE_SCOPE int TclGetWideBitsFromObj(Tcl_Interp *, Tcl_Obj *, Tcl_WideInt *); +MODULE_SCOPE int TclCompareStringKeys(void *keyPtr, Tcl_HashEntry *hPtr); +MODULE_SCOPE size_t TclHashStringKey(Tcl_HashTable *tablePtr, void *keyPtr); MODULE_SCOPE int TclIncrObj(Tcl_Interp *interp, Tcl_Obj *valuePtr, Tcl_Obj *incrPtr); MODULE_SCOPE Tcl_Obj * TclIncrObjVar2(Tcl_Interp *interp, Tcl_Obj *part1Ptr, |
