mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-09 13:29:59 -05:00
hashmap: Add pa_hashmap_remove_all()
Slightly nicer than using pa_hashmap_steal_first() in a loop.
This commit is contained in:
parent
061878b5a4
commit
31ee1a7d54
7 changed files with 23 additions and 22 deletions
|
|
@ -104,15 +104,7 @@ static void remove_entry(pa_hashmap *h, struct hashmap_entry *e) {
|
|||
void pa_hashmap_free(pa_hashmap *h, pa_free_cb_t free_cb) {
|
||||
pa_assert(h);
|
||||
|
||||
while (h->iterate_list_head) {
|
||||
void *data;
|
||||
data = h->iterate_list_head->value;
|
||||
remove_entry(h, h->iterate_list_head);
|
||||
|
||||
if (free_cb)
|
||||
free_cb(data);
|
||||
}
|
||||
|
||||
pa_hashmap_remove_all(h, free_cb);
|
||||
pa_xfree(h);
|
||||
}
|
||||
|
||||
|
|
@ -202,6 +194,19 @@ void* pa_hashmap_remove(pa_hashmap *h, const void *key) {
|
|||
return data;
|
||||
}
|
||||
|
||||
void pa_hashmap_remove_all(pa_hashmap *h, pa_free_cb_t free_cb) {
|
||||
pa_assert(h);
|
||||
|
||||
while (h->iterate_list_head) {
|
||||
void *data;
|
||||
data = h->iterate_list_head->value;
|
||||
remove_entry(h, h->iterate_list_head);
|
||||
|
||||
if (free_cb)
|
||||
free_cb(data);
|
||||
}
|
||||
}
|
||||
|
||||
void *pa_hashmap_iterate(pa_hashmap *h, void **state, const void **key) {
|
||||
struct hashmap_entry *e;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue