struct hash *hash_create_size(unsigned int size,
unsigned int (*hash_key)(void *),
- int (*hash_cmp)(const void *, const void *),
+ bool (*hash_cmp)(const void *, const void *),
const char *name)
{
struct hash *hash;
}
struct hash *hash_create(unsigned int (*hash_key)(void *),
- int (*hash_cmp)(const void *, const void *),
+ bool (*hash_cmp)(const void *, const void *),
const char *name)
{
return hash_create_size(HASH_INITIAL_SIZE, hash_key, hash_cmp, name);
unsigned int i;
struct hash_backet *hb;
struct hash_backet *hbnext;
- uint32_t count = 0;
- for (i = 0; i < hash->size; i++) {
+ for (i = 0; i < hash->size; i++)
for (hb = hash->index[i]; hb; hb = hbnext) {
/* get pointer to next hash backet here, in case (*func)
* decides to delete hb by calling hash_release
*/
hbnext = hb->next;
(*func)(hb, arg);
- count++;
-
}
- if (count == hash->count)
- return;
- }
}
void hash_walk(struct hash *hash, int (*func)(struct hash_backet *, void *),
struct hash_backet *hb;
struct hash_backet *hbnext;
int ret = HASHWALK_CONTINUE;
- uint32_t count = 0;
for (i = 0; i < hash->size; i++) {
for (hb = hash->index[i]; hb; hb = hbnext) {
ret = (*func)(hb, arg);
if (ret == HASHWALK_ABORT)
return;
- count++;
}
- if (count == hash->count)
- return;
}
}
if (_hashes) {
listnode_delete(_hashes, hash);
if (_hashes->count == 0) {
- list_delete_and_null(&_hashes);
+ list_delete(&_hashes);
}
}
}