mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-03 09:01:50 -05:00
hashmap: Use pa_free_cb_t instead of pa_free2_cb_t
The previous patch removed module-gconf's dependency on the userdata pointer of the free callback, and that was the only place where the userdata pointer of pa_free2_cb_t was used, so now there's no need for pa_free2_cb_t in pa_hashmap_free(). Using pa_free_cb_t instead allows removing a significant amount of repetitive code.
This commit is contained in:
parent
dcf043842e
commit
8872c238ba
41 changed files with 112 additions and 308 deletions
|
|
@ -326,8 +326,10 @@ static int publish_service(struct service *s) {
|
|||
finish:
|
||||
|
||||
/* Remove this service */
|
||||
if (r < 0)
|
||||
if (r < 0) {
|
||||
pa_hashmap_remove(s->userdata->services, s->device);
|
||||
service_free(s);
|
||||
}
|
||||
|
||||
avahi_string_list_free(txt);
|
||||
|
||||
|
|
@ -374,8 +376,6 @@ static struct service *get_service(struct userdata *u, pa_object *device) {
|
|||
static void service_free(struct service *s) {
|
||||
pa_assert(s);
|
||||
|
||||
pa_hashmap_remove(s->userdata->services, s->device);
|
||||
|
||||
if (s->entry_group) {
|
||||
pa_log_debug("Removing entry group for %s.", s->service_name);
|
||||
avahi_entry_group_free(s->entry_group);
|
||||
|
|
@ -413,7 +413,7 @@ static pa_hook_result_t device_unlink_cb(pa_core *c, pa_object *o, struct userda
|
|||
pa_assert(c);
|
||||
pa_object_assert_ref(o);
|
||||
|
||||
if ((s = pa_hashmap_get(u->services, o)))
|
||||
if ((s = pa_hashmap_remove(u->services, o)))
|
||||
service_free(s);
|
||||
|
||||
return PA_HOOK_OK;
|
||||
|
|
@ -661,14 +661,8 @@ void pa__done(pa_module*m) {
|
|||
if (!(u = m->userdata))
|
||||
return;
|
||||
|
||||
if (u->services) {
|
||||
struct service *s;
|
||||
|
||||
while ((s = pa_hashmap_first(u->services)))
|
||||
service_free(s);
|
||||
|
||||
pa_hashmap_free(u->services, NULL, NULL);
|
||||
}
|
||||
if (u->services)
|
||||
pa_hashmap_free(u->services, (pa_free_cb_t) service_free);
|
||||
|
||||
if (u->sink_new_slot)
|
||||
pa_hook_slot_free(u->sink_new_slot);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue