shl: hashtable: add shl_hashtable_remove() helper
This adds a helper that removes entries from a hashtable. This hasn't been needed, yet, so we never provided it. However, the new unicode-helpers will need it for proper error recovery. Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
This commit is contained in:
parent
372948af53
commit
0273802809
@ -149,6 +149,27 @@ static inline int shl_hashtable_insert(struct shl_hashtable *tbl, void *key,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline void shl_hashtable_remove(struct shl_hashtable *tbl, void *key)
|
||||
{
|
||||
struct htable_iter i;
|
||||
struct shl_hashentry *entry;
|
||||
size_t hash;
|
||||
|
||||
if (!tbl)
|
||||
return;
|
||||
|
||||
hash = tbl->hash_cb(key);
|
||||
|
||||
for (entry = htable_firstval(&tbl->tbl, &i, hash);
|
||||
entry;
|
||||
entry = htable_nextval(&tbl->tbl, &i, hash)) {
|
||||
if (tbl->equal_cb(key, entry->key)) {
|
||||
htable_delval(&tbl->tbl, &i);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static inline bool shl_hashtable_find(struct shl_hashtable *tbl, void **out,
|
||||
void *key)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user