* if it is not really necessary.
*/
if (N->Hash == Hash &&
- T->Func->Compare (Key, T->Func->GetIndex (N->Entry))) {
+ T->Func->Compare (Key, T->Func->GetKey (N->Entry))) {
/* Found */
break;
}
HT_Alloc (T);
}
- /* Generate the hash for the node contents */
- N->Hash = T->Func->GenHash (T->Func->GetIndex (N->Entry));
+ /* Generate the hash over the node key. */
+ N->Hash = T->Func->GenHash (T->Func->GetKey (N->Entry));
/* Calculate the reduced hash */
RHash = N->Hash % T->Slots;
N->Next = T->Table[RHash];
T->Table[RHash] = N;
+ /* Set the owner */
+ N->Owner = T;
+
/* One more entry */
++T->Count;
}
void* Entry; /* Pointer to user entry data */
};
-#define STATIC_HASHNODE_INITIALIZER(Entry) { 0, 0, 0, Entry }
+#define STATIC_HASHNODE_INITIALIZER(Entry) { 0, 0, 0, Entry }
/* Hash table functions */
typedef struct HashFunctions HashFunctions;
unsigned (*GenHash) (const void* Key);
/* Generate the hash over a key. */
- const void* (*GetIndex) (void* Entry);
- /* Given a pointer to the user entry data, return a pointer to the index */
+ const void* (*GetKey) (void* Entry);
+ /* Given a pointer to the user entry data, return a pointer to the key */
HashNode* (*GetHashNode) (void* Entry);
/* Given a pointer to the user entry data, return a pointer to the hash node */
#if defined(HAVE_INLINE)
INLINE void InitHashNode (HashNode* N, void* Entry)
-/* Initialize a hash node */
+/* Initialize a hash node. */
{
N->Next = 0;
N->Owner = 0;