1
0
mirror of https://github.com/cc65/cc65.git synced 2024-12-25 17:29:50 +00:00

Fix errors in tracking the number of items in the table. Added function

HT_GetCount to retrieve the number of items.


git-svn-id: svn://svn.cc65.org/cc65/trunk@5248 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
uz 2011-08-21 16:56:40 +00:00
parent ae98f4bcd8
commit d0d550be66
2 changed files with 12 additions and 0 deletions

View File

@ -194,6 +194,7 @@ void HT_Remove (HashTable* T, void* Entry)
if (*Q == N) {
/* Found - remove it */
*Q = N->Next;
--T->Count;
break;
}
/* Next node */
@ -235,6 +236,7 @@ void HT_Walk (HashTable* T, int (*F) (void* Entry, void* Data), void* Data)
if (F (*Cur, Data)) {
/* Delete the node from the chain */
*Cur = Next;
--T->Count;
} else {
/* Next node in chain */
Cur = &(*Cur)->Next;

View File

@ -139,6 +139,16 @@ INLINE HashTable* NewHashTable (unsigned Slots, const HashFunctions* Func)
void FreeHashTable (HashTable* T);
/* Free a hash table. Note: This will not free the entries in the table! */
#if defined(HAVE_INLINE)
INLINE unsigned HT_GetCount (const HashTable* T)
/* Return the number of items in the table. */
{
return T->Count;
}
#else
#define HT_GetCount(T) ((T)->Count)
#endif
HashNode* HT_FindHash (const HashTable* T, const void* Key, unsigned Hash);
/* Find the node with the given key. Differs from HT_Find in that the hash
* for the key is precalculated and passed to the function.