mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-07 13:30:03 -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -820,7 +820,7 @@ void pa__done(pa_module*m) {
|
|||
if (u->mixer_handle)
|
||||
snd_mixer_close(u->mixer_handle);
|
||||
if (u->jacks)
|
||||
pa_hashmap_free(u->jacks, NULL);
|
||||
pa_hashmap_free(u->jacks);
|
||||
|
||||
if (u->card && u->card->sinks)
|
||||
pa_idxset_remove_all(u->card->sinks, (pa_free_cb_t) pa_alsa_sink_free);
|
||||
|
|
|
|||
|
|
@ -2109,12 +2109,12 @@ void pa_bluetooth_discovery_unref(pa_bluetooth_discovery *y) {
|
|||
|
||||
if (y->devices) {
|
||||
remove_all_devices(y);
|
||||
pa_hashmap_free(y->devices, NULL);
|
||||
pa_hashmap_free(y->devices);
|
||||
}
|
||||
|
||||
if (y->transports) {
|
||||
pa_assert(pa_hashmap_isempty(y->transports));
|
||||
pa_hashmap_free(y->transports, NULL);
|
||||
pa_hashmap_free(y->transports);
|
||||
}
|
||||
|
||||
if (y->connection) {
|
||||
|
|
|
|||
|
|
@ -184,7 +184,7 @@ void pa__done(pa_module* m) {
|
|||
pa_xfree(mi);
|
||||
}
|
||||
|
||||
pa_hashmap_free(u->hashmap, NULL);
|
||||
pa_hashmap_free(u->hashmap);
|
||||
}
|
||||
|
||||
if (u->modargs)
|
||||
|
|
|
|||
|
|
@ -393,7 +393,7 @@ int pa__init(pa_module*m) {
|
|||
u->sink_name = pa_xstrdup(pa_modargs_get_value(ma, "sink", NULL));
|
||||
u->hci = pa_xstrdup(pa_modargs_get_value(ma, "hci", DEFAULT_HCI));
|
||||
u->hci_path = pa_sprintf_malloc("/org/bluez/%s", u->hci);
|
||||
u->bondings = pa_hashmap_new(pa_idxset_string_hash_func, pa_idxset_string_compare_func);
|
||||
u->bondings = pa_hashmap_new_full(pa_idxset_string_hash_func, pa_idxset_string_compare_func, NULL, (pa_free_cb_t) bonding_free);
|
||||
|
||||
if (!(u->dbus_connection = pa_dbus_bus_get(m->core, DBUS_BUS_SYSTEM, &e))) {
|
||||
pa_log("Failed to get D-Bus connection: %s", e.message);
|
||||
|
|
@ -466,7 +466,7 @@ void pa__done(pa_module*m) {
|
|||
return;
|
||||
|
||||
if (u->bondings)
|
||||
pa_hashmap_free(u->bondings, (pa_free_cb_t) bonding_free);
|
||||
pa_hashmap_free(u->bondings);
|
||||
|
||||
if (u->dbus_connection) {
|
||||
update_matches(u, false);
|
||||
|
|
|
|||
|
|
@ -495,7 +495,7 @@ static pa_hook_result_t card_profile_added_cb(void *hook_data, void *call_data,
|
|||
return PA_HOOK_OK;
|
||||
|
||||
p = pa_dbusiface_card_profile_new(c, core, profile, c->next_profile_index++);
|
||||
pa_assert_se(pa_hashmap_put(c->profiles, pa_dbusiface_card_profile_get_name(p), p) >= 0);
|
||||
pa_assert_se(pa_hashmap_put(c->profiles, (char *) pa_dbusiface_card_profile_get_name(p), p) >= 0);
|
||||
|
||||
/* Send D-Bus signal */
|
||||
object_path = pa_dbusiface_card_profile_get_path(p);
|
||||
|
|
@ -523,7 +523,8 @@ pa_dbusiface_card *pa_dbusiface_card_new(pa_dbusiface_core *core, pa_card *card)
|
|||
c->core = core;
|
||||
c->card = card;
|
||||
c->path = pa_sprintf_malloc("%s/%s%u", PA_DBUS_CORE_OBJECT_PATH, OBJECT_NAME, card->index);
|
||||
c->profiles = pa_hashmap_new(pa_idxset_string_hash_func, pa_idxset_string_compare_func);
|
||||
c->profiles = pa_hashmap_new_full(pa_idxset_string_hash_func, pa_idxset_string_compare_func, NULL,
|
||||
(pa_free_cb_t) pa_dbusiface_card_profile_free);
|
||||
c->next_profile_index = 0;
|
||||
c->active_profile = card->active_profile;
|
||||
c->proplist = pa_proplist_copy(card->proplist);
|
||||
|
|
@ -532,7 +533,7 @@ pa_dbusiface_card *pa_dbusiface_card_new(pa_dbusiface_core *core, pa_card *card)
|
|||
|
||||
PA_HASHMAP_FOREACH(profile, card->profiles, state) {
|
||||
pa_dbusiface_card_profile *p = pa_dbusiface_card_profile_new(c, card->core, profile, c->next_profile_index++);
|
||||
pa_hashmap_put(c->profiles, pa_dbusiface_card_profile_get_name(p), p);
|
||||
pa_hashmap_put(c->profiles, (char *) pa_dbusiface_card_profile_get_name(p), p);
|
||||
}
|
||||
|
||||
pa_assert_se(pa_dbus_protocol_add_interface(c->dbus_protocol, c->path, &card_interface_info, c) >= 0);
|
||||
|
|
@ -550,7 +551,7 @@ void pa_dbusiface_card_free(pa_dbusiface_card *c) {
|
|||
|
||||
pa_hook_slot_free(c->card_profile_added_slot);
|
||||
|
||||
pa_hashmap_free(c->profiles, (pa_free_cb_t) pa_dbusiface_card_profile_free);
|
||||
pa_hashmap_free(c->profiles);
|
||||
pa_proplist_free(c->proplist);
|
||||
pa_dbus_protocol_unref(c->dbus_protocol);
|
||||
pa_subscription_free(c->subscription);
|
||||
|
|
|
|||
|
|
@ -1870,7 +1870,7 @@ static pa_hook_result_t sink_put_cb(void *hook_data, void *call_data, void *slot
|
|||
object_path = pa_dbusiface_device_get_path(d);
|
||||
|
||||
pa_assert_se(pa_hashmap_put(c->sinks_by_index, PA_UINT32_TO_PTR(s->index), d) >= 0);
|
||||
pa_assert_se(pa_hashmap_put(c->sinks_by_path, object_path, d) >= 0);
|
||||
pa_assert_se(pa_hashmap_put(c->sinks_by_path, (char *) object_path, d) >= 0);
|
||||
|
||||
pa_assert_se(signal_msg = dbus_message_new_signal(PA_DBUS_CORE_OBJECT_PATH,
|
||||
PA_DBUS_CORE_INTERFACE,
|
||||
|
|
@ -1924,7 +1924,7 @@ static pa_hook_result_t source_put_cb(void *hook_data, void *call_data, void *sl
|
|||
object_path = pa_dbusiface_device_get_path(d);
|
||||
|
||||
pa_assert_se(pa_hashmap_put(c->sources_by_index, PA_UINT32_TO_PTR(s->index), d) >= 0);
|
||||
pa_assert_se(pa_hashmap_put(c->sources_by_path, object_path, d) >= 0);
|
||||
pa_assert_se(pa_hashmap_put(c->sources_by_path, (char *) object_path, d) >= 0);
|
||||
|
||||
pa_assert_se((signal_msg = dbus_message_new_signal(PA_DBUS_CORE_OBJECT_PATH,
|
||||
PA_DBUS_CORE_INTERFACE,
|
||||
|
|
@ -2021,16 +2021,20 @@ pa_dbusiface_core *pa_dbusiface_core_new(pa_core *core) {
|
|||
c->core = core;
|
||||
c->subscription = pa_subscription_new(core, PA_SUBSCRIPTION_MASK_ALL, subscription_cb, c);
|
||||
c->dbus_protocol = pa_dbus_protocol_get(core);
|
||||
c->cards = pa_hashmap_new(pa_idxset_trivial_hash_func, pa_idxset_trivial_compare_func);
|
||||
c->sinks_by_index = pa_hashmap_new(pa_idxset_trivial_hash_func, pa_idxset_trivial_compare_func);
|
||||
c->cards = pa_hashmap_new_full(pa_idxset_trivial_hash_func, pa_idxset_trivial_compare_func, NULL, (pa_free_cb_t) pa_dbusiface_card_free);
|
||||
c->sinks_by_index = pa_hashmap_new_full(pa_idxset_trivial_hash_func, pa_idxset_trivial_compare_func, NULL,
|
||||
(pa_free_cb_t) pa_dbusiface_device_free);
|
||||
c->sinks_by_path = pa_hashmap_new(pa_idxset_string_hash_func, pa_idxset_string_compare_func);
|
||||
c->sources_by_index = pa_hashmap_new(pa_idxset_trivial_hash_func, pa_idxset_trivial_compare_func);
|
||||
c->sources_by_index = pa_hashmap_new_full(pa_idxset_trivial_hash_func, pa_idxset_trivial_compare_func, NULL,
|
||||
(pa_free_cb_t) pa_dbusiface_device_free);
|
||||
c->sources_by_path = pa_hashmap_new(pa_idxset_string_hash_func, pa_idxset_string_compare_func);
|
||||
c->playback_streams = pa_hashmap_new(pa_idxset_trivial_hash_func, pa_idxset_trivial_compare_func);
|
||||
c->record_streams = pa_hashmap_new(pa_idxset_trivial_hash_func, pa_idxset_trivial_compare_func);
|
||||
c->samples = pa_hashmap_new(pa_idxset_trivial_hash_func, pa_idxset_trivial_compare_func);
|
||||
c->modules = pa_hashmap_new(pa_idxset_trivial_hash_func, pa_idxset_trivial_compare_func);
|
||||
c->clients = pa_hashmap_new(pa_idxset_trivial_hash_func, pa_idxset_trivial_compare_func);
|
||||
c->playback_streams = pa_hashmap_new_full(pa_idxset_trivial_hash_func, pa_idxset_trivial_compare_func, NULL,
|
||||
(pa_free_cb_t) pa_dbusiface_stream_free);
|
||||
c->record_streams = pa_hashmap_new_full(pa_idxset_trivial_hash_func, pa_idxset_trivial_compare_func, NULL,
|
||||
(pa_free_cb_t) pa_dbusiface_stream_free);
|
||||
c->samples = pa_hashmap_new_full(pa_idxset_trivial_hash_func, pa_idxset_trivial_compare_func, NULL, (pa_free_cb_t) pa_dbusiface_sample_free);
|
||||
c->modules = pa_hashmap_new_full(pa_idxset_trivial_hash_func, pa_idxset_trivial_compare_func, NULL, (pa_free_cb_t) pa_dbusiface_module_free);
|
||||
c->clients = pa_hashmap_new_full(pa_idxset_trivial_hash_func, pa_idxset_trivial_compare_func, NULL, (pa_free_cb_t) pa_dbusiface_client_free);
|
||||
c->fallback_sink = pa_namereg_get_default_sink(core);
|
||||
c->fallback_source = pa_namereg_get_default_source(core);
|
||||
c->sink_put_slot = pa_hook_connect(&core->hooks[PA_CORE_HOOK_SINK_PUT], PA_HOOK_NORMAL, sink_put_cb, c);
|
||||
|
|
@ -2060,13 +2064,13 @@ pa_dbusiface_core *pa_dbusiface_core_new(pa_core *core) {
|
|||
PA_IDXSET_FOREACH(sink, core->sinks, idx) {
|
||||
device = pa_dbusiface_device_new_sink(c, sink);
|
||||
pa_hashmap_put(c->sinks_by_index, PA_UINT32_TO_PTR(idx), device);
|
||||
pa_hashmap_put(c->sinks_by_path, pa_dbusiface_device_get_path(device), device);
|
||||
pa_hashmap_put(c->sinks_by_path, (char *) pa_dbusiface_device_get_path(device), device);
|
||||
}
|
||||
|
||||
PA_IDXSET_FOREACH(source, core->sources, idx) {
|
||||
device = pa_dbusiface_device_new_source(c, source);
|
||||
pa_hashmap_put(c->sources_by_index, PA_UINT32_TO_PTR(idx), device);
|
||||
pa_hashmap_put(c->sources_by_path, pa_dbusiface_device_get_path(device), device);
|
||||
pa_hashmap_put(c->sources_by_path, (char *) pa_dbusiface_device_get_path(device), device);
|
||||
}
|
||||
|
||||
PA_IDXSET_FOREACH(sink_input, core->sink_inputs, idx)
|
||||
|
|
@ -2097,16 +2101,16 @@ void pa_dbusiface_core_free(pa_dbusiface_core *c) {
|
|||
/* Note that the order of freeing is important below.
|
||||
* Do not change it for the sake of tidiness without checking! */
|
||||
pa_subscription_free(c->subscription);
|
||||
pa_hashmap_free(c->cards, (pa_free_cb_t) pa_dbusiface_card_free);
|
||||
pa_hashmap_free(c->sinks_by_path, NULL);
|
||||
pa_hashmap_free(c->sinks_by_index, (pa_free_cb_t) pa_dbusiface_device_free);
|
||||
pa_hashmap_free(c->sources_by_path, NULL);
|
||||
pa_hashmap_free(c->sources_by_index, (pa_free_cb_t) pa_dbusiface_device_free);
|
||||
pa_hashmap_free(c->playback_streams, (pa_free_cb_t) pa_dbusiface_stream_free);
|
||||
pa_hashmap_free(c->record_streams, (pa_free_cb_t) pa_dbusiface_stream_free);
|
||||
pa_hashmap_free(c->samples, (pa_free_cb_t) pa_dbusiface_sample_free);
|
||||
pa_hashmap_free(c->modules, (pa_free_cb_t) pa_dbusiface_module_free);
|
||||
pa_hashmap_free(c->clients, (pa_free_cb_t) pa_dbusiface_client_free);
|
||||
pa_hashmap_free(c->cards);
|
||||
pa_hashmap_free(c->sinks_by_path);
|
||||
pa_hashmap_free(c->sinks_by_index);
|
||||
pa_hashmap_free(c->sources_by_path);
|
||||
pa_hashmap_free(c->sources_by_index);
|
||||
pa_hashmap_free(c->playback_streams);
|
||||
pa_hashmap_free(c->record_streams);
|
||||
pa_hashmap_free(c->samples);
|
||||
pa_hashmap_free(c->modules);
|
||||
pa_hashmap_free(c->clients);
|
||||
pa_hook_slot_free(c->sink_put_slot);
|
||||
pa_hook_slot_free(c->sink_unlink_slot);
|
||||
pa_hook_slot_free(c->source_put_slot);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -336,7 +336,7 @@ int pa__init(pa_module*m) {
|
|||
u->core = m->core;
|
||||
u->module = m;
|
||||
m->userdata = u;
|
||||
u->module_infos = pa_hashmap_new(pa_idxset_string_hash_func, pa_idxset_string_compare_func);
|
||||
u->module_infos = pa_hashmap_new_full(pa_idxset_string_hash_func, pa_idxset_string_compare_func, NULL, (pa_free_cb_t) module_info_free);
|
||||
u->pid = (pid_t) -1;
|
||||
u->fd = -1;
|
||||
u->fd_type = 0;
|
||||
|
|
@ -401,7 +401,7 @@ void pa__done(pa_module*m) {
|
|||
pa_close(u->fd);
|
||||
|
||||
if (u->module_infos)
|
||||
pa_hashmap_free(u->module_infos, (pa_free_cb_t) module_info_free);
|
||||
pa_hashmap_free(u->module_infos);
|
||||
|
||||
pa_xfree(u);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -490,7 +490,7 @@ void pa__done(pa_module*m) {
|
|||
unpublish_all_services(u);
|
||||
|
||||
if (u->services)
|
||||
pa_hashmap_free(u->services, NULL);
|
||||
pa_hashmap_free(u->services);
|
||||
|
||||
if (u->sink_new_slot)
|
||||
pa_hook_slot_free(u->sink_new_slot);
|
||||
|
|
|
|||
|
|
@ -317,7 +317,7 @@ int pa__init(pa_module *m) {
|
|||
|
||||
m->userdata = u = pa_xnew(struct userdata, 1);
|
||||
|
||||
u->cache = pa_hashmap_new(pa_idxset_string_hash_func, pa_idxset_string_compare_func);
|
||||
u->cache = pa_hashmap_new_full(pa_idxset_string_hash_func, pa_idxset_string_compare_func, NULL, (pa_free_cb_t) rule_free);
|
||||
u->client_new_slot = pa_hook_connect(&m->core->hooks[PA_CORE_HOOK_CLIENT_NEW], PA_HOOK_EARLY, (pa_hook_cb_t) client_new_cb, u);
|
||||
u->client_proplist_changed_slot = pa_hook_connect(&m->core->hooks[PA_CORE_HOOK_CLIENT_PROPLIST_CHANGED], PA_HOOK_EARLY, (pa_hook_cb_t) client_proplist_changed_cb, u);
|
||||
|
||||
|
|
@ -348,7 +348,7 @@ void pa__done(pa_module *m) {
|
|||
pa_hook_slot_free(u->client_proplist_changed_slot);
|
||||
|
||||
if (u->cache)
|
||||
pa_hashmap_free(u->cache, (pa_free_cb_t) rule_free);
|
||||
pa_hashmap_free(u->cache);
|
||||
|
||||
pa_xfree(u);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -107,10 +107,17 @@ static void trigger_save(struct userdata *u) {
|
|||
u->save_time_event = pa_core_rttime_new(u->core, pa_rtclock_now() + SAVE_INTERVAL, save_time_callback, u);
|
||||
}
|
||||
|
||||
static void port_info_free(struct port_info *p_info) {
|
||||
pa_assert(p_info);
|
||||
|
||||
pa_xfree(p_info->name);
|
||||
pa_xfree(p_info);
|
||||
}
|
||||
|
||||
static struct entry* entry_new(void) {
|
||||
struct entry *r = pa_xnew0(struct entry, 1);
|
||||
r->version = ENTRY_VERSION;
|
||||
r->ports = pa_hashmap_new(pa_idxset_string_hash_func, pa_idxset_string_compare_func);
|
||||
r->ports = pa_hashmap_new_full(pa_idxset_string_hash_func, pa_idxset_string_compare_func, NULL, (pa_free_cb_t) port_info_free);
|
||||
return r;
|
||||
}
|
||||
|
||||
|
|
@ -127,18 +134,11 @@ static struct port_info *port_info_new(pa_device_port *port) {
|
|||
return p_info;
|
||||
}
|
||||
|
||||
static void port_info_free(struct port_info *p_info) {
|
||||
pa_assert(p_info);
|
||||
|
||||
pa_xfree(p_info->name);
|
||||
pa_xfree(p_info);
|
||||
}
|
||||
|
||||
static void entry_free(struct entry* e) {
|
||||
pa_assert(e);
|
||||
|
||||
pa_xfree(e->profile);
|
||||
pa_hashmap_free(e->ports, (pa_free_cb_t) port_info_free);
|
||||
pa_hashmap_free(e->ports);
|
||||
|
||||
pa_xfree(e);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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(
|
||||
|
|
|
|||
|
|
@ -1311,7 +1311,7 @@ static int extension_cb(pa_native_protocol *p, pa_module *m, pa_native_connectio
|
|||
pa_xfree(device);
|
||||
}
|
||||
|
||||
pa_hashmap_free(h, NULL);
|
||||
pa_hashmap_free(h);
|
||||
pa_log_error("Protocol error on reorder");
|
||||
goto fail;
|
||||
}
|
||||
|
|
@ -1323,7 +1323,7 @@ static int extension_cb(pa_native_protocol *p, pa_module *m, pa_native_connectio
|
|||
pa_xfree(device);
|
||||
}
|
||||
|
||||
pa_hashmap_free(h, NULL);
|
||||
pa_hashmap_free(h);
|
||||
pa_log_error("Client specified an unknown device in it's reorder list.");
|
||||
goto fail;
|
||||
}
|
||||
|
|
@ -1338,7 +1338,7 @@ static int extension_cb(pa_native_protocol *p, pa_module *m, pa_native_connectio
|
|||
pa_xfree(device);
|
||||
}
|
||||
|
||||
pa_hashmap_free(h, NULL);
|
||||
pa_hashmap_free(h);
|
||||
pa_log_error("Attempted to reorder mixed devices (sinks and sources)");
|
||||
goto fail;
|
||||
}
|
||||
|
|
@ -1411,7 +1411,7 @@ static int extension_cb(pa_native_protocol *p, pa_module *m, pa_native_connectio
|
|||
while ((device = pa_hashmap_steal_first(h))) {
|
||||
devices[idx++] = device;
|
||||
}
|
||||
pa_hashmap_free(h, NULL);
|
||||
pa_hashmap_free(h);
|
||||
|
||||
/* Simple bubble sort */
|
||||
for (i = 0; i < n_devices; ++i) {
|
||||
|
|
|
|||
|
|
@ -747,7 +747,7 @@ void pa__done(pa_module *m) {
|
|||
filter_free(f);
|
||||
}
|
||||
|
||||
pa_hashmap_free(u->filters, NULL);
|
||||
pa_hashmap_free(u->filters);
|
||||
}
|
||||
|
||||
pa_xfree(u);
|
||||
|
|
|
|||
|
|
@ -304,7 +304,7 @@ void pa__done(pa_module *m) {
|
|||
pa_hook_slot_free(u->sink_input_move_finish_slot);
|
||||
|
||||
if (u->cork_state)
|
||||
pa_hashmap_free(u->cork_state, NULL);
|
||||
pa_hashmap_free(u->cork_state);
|
||||
|
||||
pa_xfree(u);
|
||||
|
||||
|
|
|
|||
|
|
@ -2451,7 +2451,7 @@ int pa__init(pa_module*m) {
|
|||
|
||||
#ifdef HAVE_DBUS
|
||||
u->dbus_protocol = pa_dbus_protocol_get(u->core);
|
||||
u->dbus_entries = pa_hashmap_new(pa_idxset_string_hash_func, pa_idxset_string_compare_func);
|
||||
u->dbus_entries = pa_hashmap_new_full(pa_idxset_string_hash_func, pa_idxset_string_compare_func, NULL, (pa_free_cb_t) dbus_entry_free);
|
||||
|
||||
pa_assert_se(pa_dbus_protocol_add_interface(u->dbus_protocol, OBJECT_PATH, &stream_restore_interface_info, u) >= 0);
|
||||
pa_assert_se(pa_dbus_protocol_register_extension(u->dbus_protocol, INTERFACE_STREAM_RESTORE) >= 0);
|
||||
|
|
@ -2507,7 +2507,7 @@ void pa__done(pa_module*m) {
|
|||
pa_assert_se(pa_dbus_protocol_unregister_extension(u->dbus_protocol, INTERFACE_STREAM_RESTORE) >= 0);
|
||||
pa_assert_se(pa_dbus_protocol_remove_interface(u->dbus_protocol, OBJECT_PATH, stream_restore_interface_info.name) >= 0);
|
||||
|
||||
pa_hashmap_free(u->dbus_entries, (pa_free_cb_t) dbus_entry_free);
|
||||
pa_hashmap_free(u->dbus_entries);
|
||||
|
||||
pa_dbus_protocol_unref(u->dbus_protocol);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -447,7 +447,7 @@ int pa__init(pa_module*m) {
|
|||
m->userdata = u = pa_xnew(struct userdata, 1);
|
||||
u->core = m->core;
|
||||
u->timeout = timeout * PA_USEC_PER_SEC;
|
||||
u->device_infos = pa_hashmap_new(pa_idxset_trivial_hash_func, pa_idxset_trivial_compare_func);
|
||||
u->device_infos = pa_hashmap_new_full(pa_idxset_trivial_hash_func, pa_idxset_trivial_compare_func, NULL, (pa_free_cb_t) device_info_free);
|
||||
|
||||
PA_IDXSET_FOREACH(sink, m->core->sinks, idx)
|
||||
device_new_hook_cb(m->core, PA_OBJECT(sink), u);
|
||||
|
|
@ -530,7 +530,7 @@ void pa__done(pa_module*m) {
|
|||
if (u->source_output_state_changed_slot)
|
||||
pa_hook_slot_free(u->source_output_state_changed_slot);
|
||||
|
||||
pa_hashmap_free(u->device_infos, (pa_free_cb_t) device_info_free);
|
||||
pa_hashmap_free(u->device_infos);
|
||||
|
||||
pa_xfree(u);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -140,7 +140,7 @@ static int get_session_list(struct userdata *u) {
|
|||
free(sessions);
|
||||
}
|
||||
|
||||
pa_hashmap_remove_all(u->previous_sessions, (pa_free_cb_t) free_session);
|
||||
pa_hashmap_remove_all(u->previous_sessions);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -187,8 +187,8 @@ int pa__init(pa_module *m) {
|
|||
m->userdata = u = pa_xnew0(struct userdata, 1);
|
||||
u->core = m->core;
|
||||
u->module = m;
|
||||
u->sessions = pa_hashmap_new(pa_idxset_string_hash_func, pa_idxset_string_compare_func);
|
||||
u->previous_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);
|
||||
u->previous_sessions = pa_hashmap_new_full(pa_idxset_string_hash_func, pa_idxset_string_compare_func, NULL, (pa_free_cb_t) free_session);
|
||||
u->monitor = monitor;
|
||||
|
||||
u->io = u->core->mainloop->io_new(u->core->mainloop, sd_login_monitor_get_fd(monitor), PA_IO_EVENT_INPUT, monitor_cb, u);
|
||||
|
|
@ -219,8 +219,8 @@ 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->previous_sessions, (pa_free_cb_t) free_session);
|
||||
pa_hashmap_free(u->sessions);
|
||||
pa_hashmap_free(u->previous_sessions);
|
||||
}
|
||||
|
||||
if (u->io)
|
||||
|
|
|
|||
|
|
@ -700,7 +700,7 @@ int pa__init(pa_module *m) {
|
|||
|
||||
m->userdata = u = pa_xnew0(struct userdata, 1);
|
||||
u->core = m->core;
|
||||
u->devices = pa_hashmap_new(pa_idxset_string_hash_func, pa_idxset_string_compare_func);
|
||||
u->devices = pa_hashmap_new_full(pa_idxset_string_hash_func, pa_idxset_string_compare_func, NULL, (pa_free_cb_t) device_free);
|
||||
u->inotify_fd = -1;
|
||||
|
||||
if (pa_modargs_get_value_boolean(ma, "tsched", &use_tsched) < 0) {
|
||||
|
|
@ -841,7 +841,7 @@ void pa__done(pa_module *m) {
|
|||
pa_close(u->inotify_fd);
|
||||
|
||||
if (u->devices)
|
||||
pa_hashmap_free(u->devices, (pa_free_cb_t) device_free);
|
||||
pa_hashmap_free(u->devices);
|
||||
|
||||
pa_xfree(u);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -426,7 +426,7 @@ void pa__done(pa_module*m) {
|
|||
tunnel_free(t);
|
||||
}
|
||||
|
||||
pa_hashmap_free(u->tunnels, NULL);
|
||||
pa_hashmap_free(u->tunnels);
|
||||
}
|
||||
|
||||
pa_xfree(u);
|
||||
|
|
|
|||
|
|
@ -745,7 +745,7 @@ int pa__init(pa_module*m) {
|
|||
|
||||
u->avahi_poll = pa_avahi_poll_new(u->api);
|
||||
|
||||
u->services = pa_hashmap_new(pa_idxset_trivial_hash_func, pa_idxset_trivial_compare_func);
|
||||
u->services = pa_hashmap_new_full(pa_idxset_trivial_hash_func, pa_idxset_trivial_compare_func, NULL, (pa_free_cb_t) service_free);
|
||||
|
||||
u->sink_new_slot = pa_hook_connect(&m->core->hooks[PA_CORE_HOOK_SINK_PUT], PA_HOOK_LATE, (pa_hook_cb_t) device_new_or_changed_cb, u);
|
||||
u->sink_changed_slot = pa_hook_connect(&m->core->hooks[PA_CORE_HOOK_SINK_PROPLIST_CHANGED], PA_HOOK_LATE, (pa_hook_cb_t) device_new_or_changed_cb, u);
|
||||
|
|
@ -786,7 +786,7 @@ fail:
|
|||
static void client_free(pa_mainloop_api *api PA_GCC_UNUSED, void *userdata) {
|
||||
struct userdata *u = (struct userdata *) userdata;
|
||||
|
||||
pa_hashmap_free(u->services, (pa_free_cb_t) service_free);
|
||||
pa_hashmap_free(u->services);
|
||||
|
||||
if (u->main_entry_group)
|
||||
avahi_entry_group_free(u->main_entry_group);
|
||||
|
|
|
|||
|
|
@ -381,7 +381,7 @@ void pa__done(pa_module*m) {
|
|||
tunnel_free(t);
|
||||
}
|
||||
|
||||
pa_hashmap_free(u->tunnels, NULL);
|
||||
pa_hashmap_free(u->tunnels);
|
||||
}
|
||||
|
||||
pa_xfree(u);
|
||||
|
|
|
|||
|
|
@ -52,11 +52,11 @@ static void header_free(struct header *hdr) {
|
|||
}
|
||||
|
||||
pa_headerlist* pa_headerlist_new(void) {
|
||||
return MAKE_HEADERLIST(pa_hashmap_new(pa_idxset_string_hash_func, pa_idxset_string_compare_func));
|
||||
return MAKE_HEADERLIST(pa_hashmap_new_full(pa_idxset_string_hash_func, pa_idxset_string_compare_func, NULL, (pa_free_cb_t) header_free));
|
||||
}
|
||||
|
||||
void pa_headerlist_free(pa_headerlist* p) {
|
||||
pa_hashmap_free(MAKE_HASHMAP(p), (pa_free_cb_t) header_free);
|
||||
pa_hashmap_free(MAKE_HASHMAP(p));
|
||||
}
|
||||
|
||||
int pa_headerlist_puts(pa_headerlist *p, const char *key, const char *value) {
|
||||
|
|
|
|||
|
|
@ -735,7 +735,7 @@ int pa__init(pa_module*m) {
|
|||
|
||||
PA_LLIST_HEAD_INIT(struct session, u->sessions);
|
||||
u->n_sessions = 0;
|
||||
u->by_origin = pa_hashmap_new(pa_idxset_string_hash_func, pa_idxset_string_compare_func);
|
||||
u->by_origin = pa_hashmap_new_full(pa_idxset_string_hash_func, pa_idxset_string_compare_func, NULL, (pa_free_cb_t) session_free);
|
||||
|
||||
u->check_death_event = pa_core_rttime_new(m->core, pa_rtclock_now() + DEATH_TIMEOUT * PA_USEC_PER_SEC, check_death_event_cb, u);
|
||||
|
||||
|
|
@ -770,7 +770,7 @@ void pa__done(pa_module*m) {
|
|||
pa_sap_context_destroy(&u->sap_context);
|
||||
|
||||
if (u->by_origin)
|
||||
pa_hashmap_free(u->by_origin, (pa_free_cb_t) session_free);
|
||||
pa_hashmap_free(u->by_origin);
|
||||
|
||||
pa_xfree(u->sink_name);
|
||||
pa_xfree(u);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue