mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-21 06:59: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
|
|
@ -1214,7 +1214,7 @@ pa_dbusiface_device *pa_dbusiface_device_new_sink(pa_dbusiface_core *core, pa_si
|
|||
d->volume = *pa_sink_get_volume(sink, false);
|
||||
d->mute = pa_sink_get_mute(sink, false);
|
||||
d->sink_state = pa_sink_get_state(sink);
|
||||
d->ports = pa_hashmap_new(pa_idxset_string_hash_func, pa_idxset_string_compare_func);
|
||||
d->ports = pa_hashmap_new_full(pa_idxset_string_hash_func, pa_idxset_string_compare_func, NULL, (pa_free_cb_t) pa_dbusiface_device_port_free);
|
||||
d->next_port_index = 0;
|
||||
d->active_port = sink->active_port;
|
||||
d->proplist = pa_proplist_copy(sink->proplist);
|
||||
|
|
@ -1223,7 +1223,7 @@ pa_dbusiface_device *pa_dbusiface_device_new_sink(pa_dbusiface_core *core, pa_si
|
|||
|
||||
PA_HASHMAP_FOREACH(port, sink->ports, state) {
|
||||
pa_dbusiface_device_port *p = pa_dbusiface_device_port_new(d, sink->core, port, d->next_port_index++);
|
||||
pa_hashmap_put(d->ports, pa_dbusiface_device_port_get_name(p), p);
|
||||
pa_hashmap_put(d->ports, (char *) pa_dbusiface_device_port_get_name(p), p);
|
||||
}
|
||||
|
||||
pa_assert_se(pa_dbus_protocol_add_interface(d->dbus_protocol, d->path, &device_interface_info, d) >= 0);
|
||||
|
|
@ -1257,7 +1257,7 @@ pa_dbusiface_device *pa_dbusiface_device_new_source(pa_dbusiface_core *core, pa_
|
|||
|
||||
PA_HASHMAP_FOREACH(port, source->ports, state) {
|
||||
pa_dbusiface_device_port *p = pa_dbusiface_device_port_new(d, source->core, port, d->next_port_index++);
|
||||
pa_hashmap_put(d->ports, pa_dbusiface_device_port_get_name(p), p);
|
||||
pa_hashmap_put(d->ports, (char *) pa_dbusiface_device_port_get_name(p), p);
|
||||
}
|
||||
|
||||
pa_assert_se(pa_dbus_protocol_add_interface(d->dbus_protocol, d->path, &device_interface_info, d) >= 0);
|
||||
|
|
@ -1279,7 +1279,7 @@ void pa_dbusiface_device_free(pa_dbusiface_device *d) {
|
|||
pa_assert_se(pa_dbus_protocol_remove_interface(d->dbus_protocol, d->path, source_interface_info.name) >= 0);
|
||||
pa_source_unref(d->source);
|
||||
}
|
||||
pa_hashmap_free(d->ports, (pa_free_cb_t) pa_dbusiface_device_port_free);
|
||||
pa_hashmap_free(d->ports);
|
||||
pa_proplist_free(d->proplist);
|
||||
pa_dbus_protocol_unref(d->dbus_protocol);
|
||||
pa_subscription_free(d->subscription);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue