mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-04 13:29:59 -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
|
|
@ -169,8 +169,8 @@ void pa_dbus_protocol_unref(pa_dbus_protocol *p) {
|
|||
pa_assert(pa_hashmap_isempty(p->connections));
|
||||
pa_assert(pa_idxset_isempty(p->extensions));
|
||||
|
||||
pa_hashmap_free(p->objects, NULL, NULL);
|
||||
pa_hashmap_free(p->connections, NULL, NULL);
|
||||
pa_hashmap_free(p->objects, NULL);
|
||||
pa_hashmap_free(p->connections, NULL);
|
||||
pa_idxset_free(p->extensions, NULL, NULL);
|
||||
|
||||
for (i = 0; i < PA_DBUS_PROTOCOL_HOOK_MAX; ++i)
|
||||
|
|
@ -789,8 +789,7 @@ static void unregister_object(pa_dbus_protocol *p, struct object_entry *obj_entr
|
|||
pa_assert_se(dbus_connection_unregister_object_path(conn_entry->connection, obj_entry->path));
|
||||
}
|
||||
|
||||
static void method_handler_free_cb(void *p, void *userdata) {
|
||||
pa_dbus_method_handler *h = p;
|
||||
static void method_handler_free(pa_dbus_method_handler *h) {
|
||||
unsigned i;
|
||||
|
||||
pa_assert(h);
|
||||
|
|
@ -807,15 +806,7 @@ static void method_handler_free_cb(void *p, void *userdata) {
|
|||
pa_xfree(h);
|
||||
}
|
||||
|
||||
static void method_signature_free_cb(void *p, void *userdata) {
|
||||
pa_assert(p);
|
||||
|
||||
pa_xfree(p);
|
||||
}
|
||||
|
||||
static void property_handler_free_cb(void *p, void *userdata) {
|
||||
pa_dbus_property_handler *h = p;
|
||||
|
||||
static void property_handler_free(pa_dbus_property_handler *h) {
|
||||
pa_assert(h);
|
||||
|
||||
pa_xfree((char *) h->property_name);
|
||||
|
|
@ -844,9 +835,9 @@ int pa_dbus_protocol_remove_interface(pa_dbus_protocol *p, const char* path, con
|
|||
pa_log_debug("Interface %s removed from object %s", iface_entry->name, obj_entry->path);
|
||||
|
||||
pa_xfree(iface_entry->name);
|
||||
pa_hashmap_free(iface_entry->method_signatures, method_signature_free_cb, NULL);
|
||||
pa_hashmap_free(iface_entry->method_handlers, method_handler_free_cb, NULL);
|
||||
pa_hashmap_free(iface_entry->property_handlers, property_handler_free_cb, NULL);
|
||||
pa_hashmap_free(iface_entry->method_signatures, pa_xfree);
|
||||
pa_hashmap_free(iface_entry->method_handlers, (pa_free_cb_t) method_handler_free);
|
||||
pa_hashmap_free(iface_entry->property_handlers, (pa_free_cb_t) property_handler_free);
|
||||
|
||||
for (i = 0; i < iface_entry->n_signals; ++i) {
|
||||
unsigned j;
|
||||
|
|
@ -870,7 +861,7 @@ int pa_dbus_protocol_remove_interface(pa_dbus_protocol *p, const char* path, con
|
|||
|
||||
pa_hashmap_remove(p->objects, path);
|
||||
pa_xfree(obj_entry->path);
|
||||
pa_hashmap_free(obj_entry->interfaces, NULL, NULL);
|
||||
pa_hashmap_free(obj_entry->interfaces, NULL);
|
||||
pa_xfree(obj_entry->introspection);
|
||||
pa_xfree(obj_entry);
|
||||
}
|
||||
|
|
@ -952,7 +943,6 @@ static void signal_paths_entry_free(struct signal_paths_entry *e) {
|
|||
|
||||
int pa_dbus_protocol_unregister_connection(pa_dbus_protocol *p, DBusConnection *conn) {
|
||||
struct connection_entry *conn_entry = NULL;
|
||||
struct signal_paths_entry *signal_paths_entry = NULL;
|
||||
char *object_path = NULL;
|
||||
|
||||
pa_assert(p);
|
||||
|
|
@ -970,10 +960,7 @@ int pa_dbus_protocol_unregister_connection(pa_dbus_protocol *p, DBusConnection *
|
|||
|
||||
pa_idxset_free(conn_entry->all_signals_objects, NULL, NULL);
|
||||
|
||||
while ((signal_paths_entry = pa_hashmap_steal_first(conn_entry->listening_signals)))
|
||||
signal_paths_entry_free(signal_paths_entry);
|
||||
|
||||
pa_hashmap_free(conn_entry->listening_signals, NULL, NULL);
|
||||
pa_hashmap_free(conn_entry->listening_signals, (pa_free_cb_t) signal_paths_entry_free);
|
||||
pa_xfree(conn_entry);
|
||||
|
||||
return 0;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue