mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-06 13:29:56 -05:00
hashmap: Add the ability to free keys
Since the hashmap stores a pointer to the key provided at pa_hashmap_put() time, it make sense to allow the hashmap to be given ownership of the key and have it free it at pa_hashmap_remove/free time. To do this cleanly, we now provide the key and value free functions at hashmap creation time with a pa_hashmap_new_full. With this, we do away with the free function that was provided at remove/free time for freeing the value.
This commit is contained in:
parent
317b46b571
commit
6825df8cec
41 changed files with 232 additions and 205 deletions
|
|
@ -64,13 +64,13 @@ static void property_free(struct property *prop) {
|
|||
}
|
||||
|
||||
pa_proplist* pa_proplist_new(void) {
|
||||
return MAKE_PROPLIST(pa_hashmap_new(pa_idxset_string_hash_func, pa_idxset_string_compare_func));
|
||||
return MAKE_PROPLIST(pa_hashmap_new_full(pa_idxset_string_hash_func, pa_idxset_string_compare_func, NULL, (pa_free_cb_t) property_free));
|
||||
}
|
||||
|
||||
void pa_proplist_free(pa_proplist* p) {
|
||||
pa_assert(p);
|
||||
|
||||
pa_hashmap_free(MAKE_HASHMAP(p), (pa_free_cb_t) property_free);
|
||||
pa_hashmap_free(MAKE_HASHMAP(p));
|
||||
}
|
||||
|
||||
/** Will accept only valid UTF-8 */
|
||||
|
|
@ -654,7 +654,7 @@ int pa_proplist_contains(pa_proplist *p, const char *key) {
|
|||
void pa_proplist_clear(pa_proplist *p) {
|
||||
pa_assert(p);
|
||||
|
||||
pa_hashmap_remove_all(MAKE_HASHMAP(p), (pa_free_cb_t) property_free);
|
||||
pa_hashmap_remove_all(MAKE_HASHMAP(p));
|
||||
}
|
||||
|
||||
pa_proplist* pa_proplist_copy(const pa_proplist *p) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue