[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
hash locate_matching_entry()
From: |
Jason Stover |
Subject: |
hash locate_matching_entry() |
Date: |
Wed, 8 Oct 2008 10:25:19 -0400 |
User-agent: |
Mutt/1.5.18 (2008-05-17) |
I'm having some trouble getting a matching entry in my
hash table. It looks like the problem is here:
/* Locates an entry matching TARGET. Returns the index for the
entry, if found, or the index of an empty entry that indicates
where TARGET should go, otherwise. */
static inline unsigned
locate_matching_entry (struct hsh_table *h, const void *target)
{
unsigned i = h->hash (target, h->aux);
assert (h->hash_ordered);
for (;;)
{
void *entry;
i &= h->size - 1;
entry = h->entries[i];
if (entry == NULL || !h->compare (entry, target, h->aux))
return i;
i--;
}
}
In my code, h->compare (entry, target, h->aux) returns 1 when
entry and target match. So I would think locate_matching_entry()
should return i, but it doesn't because of the !h->compare (...).
Should this line be:
if (entry == NULL || h->compare (entry, target, h->aux))
??
-Jason
- hash locate_matching_entry(),
Jason Stover <=