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
|
|
@ -530,7 +530,7 @@ void pa_alsa_path_set_free(pa_alsa_path_set *ps) {
|
|||
pa_assert(ps);
|
||||
|
||||
if (ps->paths)
|
||||
pa_hashmap_free(ps->paths, NULL);
|
||||
pa_hashmap_free(ps->paths);
|
||||
|
||||
pa_xfree(ps);
|
||||
}
|
||||
|
|
@ -3337,19 +3337,19 @@ void pa_alsa_profile_set_free(pa_alsa_profile_set *ps) {
|
|||
pa_assert(ps);
|
||||
|
||||
if (ps->input_paths)
|
||||
pa_hashmap_free(ps->input_paths, (pa_free_cb_t) pa_alsa_path_free);
|
||||
pa_hashmap_free(ps->input_paths);
|
||||
|
||||
if (ps->output_paths)
|
||||
pa_hashmap_free(ps->output_paths, (pa_free_cb_t) pa_alsa_path_free);
|
||||
pa_hashmap_free(ps->output_paths);
|
||||
|
||||
if (ps->profiles)
|
||||
pa_hashmap_free(ps->profiles, (pa_free_cb_t) profile_free);
|
||||
pa_hashmap_free(ps->profiles);
|
||||
|
||||
if (ps->mappings)
|
||||
pa_hashmap_free(ps->mappings, (pa_free_cb_t) mapping_free);
|
||||
pa_hashmap_free(ps->mappings);
|
||||
|
||||
if (ps->decibel_fixes)
|
||||
pa_hashmap_free(ps->decibel_fixes, (pa_free_cb_t) decibel_fix_free);
|
||||
pa_hashmap_free(ps->decibel_fixes);
|
||||
|
||||
pa_xfree(ps);
|
||||
}
|
||||
|
|
@ -3776,7 +3776,7 @@ static void mapping_paths_probe(pa_alsa_mapping *m, pa_alsa_profile *profile,
|
|||
mixer_handle = pa_alsa_open_mixer_for_pcm(pcm_handle, NULL, &hctl_handle);
|
||||
if (!mixer_handle || !hctl_handle) {
|
||||
/* Cannot open mixer, remove all entries */
|
||||
pa_hashmap_remove_all(ps->paths, NULL);
|
||||
pa_hashmap_remove_all(ps->paths);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -4167,11 +4167,11 @@ pa_alsa_profile_set* pa_alsa_profile_set_new(const char *fname, const pa_channel
|
|||
};
|
||||
|
||||
ps = pa_xnew0(pa_alsa_profile_set, 1);
|
||||
ps->mappings = pa_hashmap_new(pa_idxset_string_hash_func, pa_idxset_string_compare_func);
|
||||
ps->profiles = pa_hashmap_new(pa_idxset_string_hash_func, pa_idxset_string_compare_func);
|
||||
ps->decibel_fixes = pa_hashmap_new(pa_idxset_string_hash_func, pa_idxset_string_compare_func);
|
||||
ps->input_paths = pa_hashmap_new(pa_idxset_string_hash_func, pa_idxset_string_compare_func);
|
||||
ps->output_paths = pa_hashmap_new(pa_idxset_string_hash_func, pa_idxset_string_compare_func);
|
||||
ps->mappings = pa_hashmap_new_full(pa_idxset_string_hash_func, pa_idxset_string_compare_func, NULL, (pa_free_cb_t) mapping_free);
|
||||
ps->profiles = pa_hashmap_new_full(pa_idxset_string_hash_func, pa_idxset_string_compare_func, NULL, (pa_free_cb_t) profile_free);
|
||||
ps->decibel_fixes = pa_hashmap_new_full(pa_idxset_string_hash_func, pa_idxset_string_compare_func, NULL, (pa_free_cb_t) decibel_fix_free);
|
||||
ps->input_paths = pa_hashmap_new_full(pa_idxset_string_hash_func, pa_idxset_string_compare_func, NULL, (pa_free_cb_t) pa_alsa_path_free);
|
||||
ps->output_paths = pa_hashmap_new_full(pa_idxset_string_hash_func, pa_idxset_string_compare_func, NULL, (pa_free_cb_t) pa_alsa_path_free);
|
||||
|
||||
items[0].data = &ps->auto_profiles;
|
||||
|
||||
|
|
@ -4420,8 +4420,8 @@ void pa_alsa_profile_set_probe(
|
|||
|
||||
paths_drop_unsupported(ps->input_paths);
|
||||
paths_drop_unsupported(ps->output_paths);
|
||||
pa_hashmap_free(broken_inputs, NULL);
|
||||
pa_hashmap_free(broken_outputs, NULL);
|
||||
pa_hashmap_free(broken_inputs);
|
||||
pa_hashmap_free(broken_outputs);
|
||||
|
||||
ps->probed = true;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue