diff options
author | Tanu Kaskinen <tanuk@iki.fi> | 2013-02-12 21:36:53 +0200 |
---|---|---|
committer | Tanu Kaskinen <tanuk@iki.fi> | 2013-02-16 01:12:21 +0200 |
commit | 8872c238ba6748c76455ecc6827b83ebcb1dd469 (patch) | |
tree | 1f73094f08088d08ded489f479cbf54ab7769214 /src/modules/dbus | |
parent | dcf043842e6bef0680bb246e7266b7c0829d34d4 (diff) | |
download | pulseaudio-8872c238ba6748c76455ecc6827b83ebcb1dd469.tar.gz |
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.
Diffstat (limited to 'src/modules/dbus')
-rw-r--r-- | src/modules/dbus/iface-card.c | 10 | ||||
-rw-r--r-- | src/modules/dbus/iface-core.c | 68 | ||||
-rw-r--r-- | src/modules/dbus/iface-device.c | 10 |
3 files changed, 12 insertions, 76 deletions
diff --git a/src/modules/dbus/iface-card.c b/src/modules/dbus/iface-card.c index 1313e71bf..945f5bb76 100644 --- a/src/modules/dbus/iface-card.c +++ b/src/modules/dbus/iface-card.c @@ -543,14 +543,6 @@ pa_dbusiface_card *pa_dbusiface_card_new(pa_dbusiface_core *core, pa_card *card) return c; } -static void profile_free_cb(void *p, void *userdata) { - pa_dbusiface_card_profile *profile = p; - - pa_assert(profile); - - pa_dbusiface_card_profile_free(profile); -} - void pa_dbusiface_card_free(pa_dbusiface_card *c) { pa_assert(c); @@ -558,7 +550,7 @@ void pa_dbusiface_card_free(pa_dbusiface_card *c) { pa_hook_slot_free(c->card_profile_added_slot); - pa_hashmap_free(c->profiles, profile_free_cb, NULL); + pa_hashmap_free(c->profiles, (pa_free_cb_t) pa_dbusiface_card_profile_free); pa_proplist_free(c->proplist); pa_dbus_protocol_unref(c->dbus_protocol); pa_subscription_free(c->subscription); diff --git a/src/modules/dbus/iface-core.c b/src/modules/dbus/iface-core.c index 97a46a58d..a9716bc33 100644 --- a/src/modules/dbus/iface-core.c +++ b/src/modules/dbus/iface-core.c @@ -2089,54 +2089,6 @@ pa_dbusiface_core *pa_dbusiface_core_new(pa_core *core) { return c; } -static void free_card_cb(void *p, void *userdata) { - pa_dbusiface_card *c = p; - - pa_assert(c); - - pa_dbusiface_card_free(c); -} - -static void free_device_cb(void *p, void *userdata) { - pa_dbusiface_device *d = p; - - pa_assert(d); - - pa_dbusiface_device_free(d); -} - -static void free_stream_cb(void *p, void *userdata) { - pa_dbusiface_stream *s = p; - - pa_assert(s); - - pa_dbusiface_stream_free(s); -} - -static void free_sample_cb(void *p, void *userdata) { - pa_dbusiface_sample *s = p; - - pa_assert(s); - - pa_dbusiface_sample_free(s); -} - -static void free_module_cb(void *p, void *userdata) { - pa_dbusiface_module *m = p; - - pa_assert(m); - - pa_dbusiface_module_free(m); -} - -static void free_client_cb(void *p, void *userdata) { - pa_dbusiface_client *c = p; - - pa_assert(c); - - pa_dbusiface_client_free(c); -} - void pa_dbusiface_core_free(pa_dbusiface_core *c) { pa_assert(c); @@ -2145,16 +2097,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, free_card_cb, NULL); - pa_hashmap_free(c->sinks_by_path, NULL, NULL); - pa_hashmap_free(c->sinks_by_index, free_device_cb, NULL); - pa_hashmap_free(c->sources_by_path, NULL, NULL); - pa_hashmap_free(c->sources_by_index, free_device_cb, NULL); - pa_hashmap_free(c->playback_streams, free_stream_cb, NULL); - pa_hashmap_free(c->record_streams, free_stream_cb, NULL); - pa_hashmap_free(c->samples, free_sample_cb, NULL); - pa_hashmap_free(c->modules, free_module_cb, NULL); - pa_hashmap_free(c->clients, free_client_cb, NULL); + 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_hook_slot_free(c->sink_put_slot); pa_hook_slot_free(c->sink_unlink_slot); pa_hook_slot_free(c->source_put_slot); diff --git a/src/modules/dbus/iface-device.c b/src/modules/dbus/iface-device.c index 151938dfb..888d407eb 100644 --- a/src/modules/dbus/iface-device.c +++ b/src/modules/dbus/iface-device.c @@ -1266,14 +1266,6 @@ pa_dbusiface_device *pa_dbusiface_device_new_source(pa_dbusiface_core *core, pa_ return d; } -static void port_free_cb(void *p, void *userdata) { - pa_dbusiface_device_port *port = p; - - pa_assert(port); - - pa_dbusiface_device_port_free(port); -} - void pa_dbusiface_device_free(pa_dbusiface_device *d) { pa_assert(d); @@ -1287,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, port_free_cb, NULL); + pa_hashmap_free(d->ports, (pa_free_cb_t) pa_dbusiface_device_port_free); pa_proplist_free(d->proplist); pa_dbus_protocol_unref(d->dbus_protocol); pa_subscription_free(d->subscription); |