mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-05 13:29:57 -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
|
|
@ -109,8 +109,10 @@ pa_sink_input_new_data* pa_sink_input_new_data_init(pa_sink_input_new_data *data
|
|||
data->proplist = pa_proplist_new();
|
||||
data->volume_writable = true;
|
||||
|
||||
data->volume_factor_items = pa_hashmap_new(pa_idxset_string_hash_func, pa_idxset_string_compare_func);
|
||||
data->volume_factor_sink_items = pa_hashmap_new(pa_idxset_string_hash_func, pa_idxset_string_compare_func);
|
||||
data->volume_factor_items = pa_hashmap_new_full(pa_idxset_string_hash_func, pa_idxset_string_compare_func, NULL,
|
||||
(pa_free_cb_t) volume_factor_entry_free);
|
||||
data->volume_factor_sink_items = pa_hashmap_new_full(pa_idxset_string_hash_func, pa_idxset_string_compare_func, NULL,
|
||||
(pa_free_cb_t) volume_factor_entry_free);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
|
@ -241,10 +243,10 @@ void pa_sink_input_new_data_done(pa_sink_input_new_data *data) {
|
|||
pa_format_info_free(data->format);
|
||||
|
||||
if (data->volume_factor_items)
|
||||
pa_hashmap_free(data->volume_factor_items, (pa_free_cb_t) volume_factor_entry_free);
|
||||
pa_hashmap_free(data->volume_factor_items);
|
||||
|
||||
if (data->volume_factor_sink_items)
|
||||
pa_hashmap_free(data->volume_factor_sink_items, (pa_free_cb_t) volume_factor_entry_free);
|
||||
pa_hashmap_free(data->volume_factor_sink_items);
|
||||
|
||||
pa_proplist_free(data->proplist);
|
||||
}
|
||||
|
|
@ -766,13 +768,13 @@ static void sink_input_free(pa_object *o) {
|
|||
pa_idxset_free(i->direct_outputs, NULL);
|
||||
|
||||
if (i->thread_info.direct_outputs)
|
||||
pa_hashmap_free(i->thread_info.direct_outputs, NULL);
|
||||
pa_hashmap_free(i->thread_info.direct_outputs);
|
||||
|
||||
if (i->volume_factor_items)
|
||||
pa_hashmap_free(i->volume_factor_items, (pa_free_cb_t) volume_factor_entry_free);
|
||||
pa_hashmap_free(i->volume_factor_items);
|
||||
|
||||
if (i->volume_factor_sink_items)
|
||||
pa_hashmap_free(i->volume_factor_sink_items, (pa_free_cb_t) volume_factor_entry_free);
|
||||
pa_hashmap_free(i->volume_factor_sink_items);
|
||||
|
||||
pa_xfree(i->driver);
|
||||
pa_xfree(i);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue