mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-04 13:29:59 -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
|
|
@ -303,7 +303,7 @@ int pa__init(pa_module*m) {
|
|||
u->core = m->core;
|
||||
u->module = m;
|
||||
u->connection = connection;
|
||||
u->sessions = pa_hashmap_new(pa_idxset_string_hash_func, pa_idxset_string_compare_func);
|
||||
u->sessions = pa_hashmap_new_full(pa_idxset_string_hash_func, pa_idxset_string_compare_func, NULL, (pa_free_cb_t) free_session);
|
||||
|
||||
if (!dbus_connection_add_filter(pa_dbus_connection_get(connection), filter_cb, u, NULL)) {
|
||||
pa_log_error("Failed to add filter function");
|
||||
|
|
@ -346,7 +346,7 @@ void pa__done(pa_module *m) {
|
|||
return;
|
||||
|
||||
if (u->sessions)
|
||||
pa_hashmap_free(u->sessions, (pa_free_cb_t) free_session);
|
||||
pa_hashmap_free(u->sessions);
|
||||
|
||||
if (u->connection) {
|
||||
pa_dbus_remove_matches(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue