diff options
author | Peng Huang <shawn.p.huang@gmail.com> | 2011-11-30 16:37:39 -0500 |
---|---|---|
committer | Peng Huang <shawn.p.huang@gmail.com> | 2012-02-21 11:50:22 -0500 |
commit | 436516f78b26c5e2201e35f0af6fa60745a84dd0 (patch) | |
tree | 3a103f0e58e311fd10d8c535ee8409099d36eaf8 /bus | |
parent | 1983e58d9f4f7471bcd1e59b2ef7729ca3fecc25 (diff) |
Use g_list_free_full to simplified some code.
Diffstat (limited to 'bus')
-rw-r--r-- | bus/connection.c | 3 | ||||
-rw-r--r-- | bus/dbusimpl.c | 20 | ||||
-rw-r--r-- | bus/ibusimpl.c | 6 | ||||
-rw-r--r-- | bus/registry.c | 6 |
4 files changed, 9 insertions, 26 deletions
diff --git a/bus/connection.c b/bus/connection.c index 9e73213a..5273fcc1 100644 --- a/bus/connection.c +++ b/bus/connection.c @@ -101,8 +101,7 @@ bus_connection_destroy (BusConnection *connection) connection->unique_name = NULL; } - g_list_foreach (connection->names, (GFunc) g_free, NULL); - g_list_free (connection->names); + g_list_free_full (connection->names, g_free); connection->names = NULL; IBUS_OBJECT_CLASS(bus_connection_parent_class)->destroy (IBUS_OBJECT (connection)); diff --git a/bus/dbusimpl.c b/bus/dbusimpl.c index 2261af09..231a19ac 100644 --- a/bus/dbusimpl.c +++ b/bus/dbusimpl.c @@ -331,17 +331,8 @@ bus_name_service_free (BusNameService *service) g_assert (service != NULL); - list = service->owners; - - while (list) { - bus_connection_owner_free ((BusConnectionOwner *) list->data); - list->data = NULL; - list = list->next; - } - if (service->owners) { - g_slist_free (service->owners); - service->owners = NULL; - } + g_slist_free_full (service->owners, (GDestroyNotify)bus_connection_owner_free); + service->owners = NULL; g_free (service->name); g_slice_free (BusNameService, service); @@ -636,9 +627,7 @@ bus_dbus_impl_destroy (BusDBusImpl *dbus) dbus->unique_names = NULL; dbus->names = NULL; - g_list_foreach (dbus->start_service_calls, - (GFunc) bus_method_call_free, NULL); - g_list_free (dbus->start_service_calls); + g_list_free_full (dbus->start_service_calls, (GDestroyNotify)bus_method_call_free); dbus->start_service_calls = NULL; /* FIXME destruct _lock and _queue members. */ @@ -1840,8 +1829,7 @@ bus_dbus_impl_dispatch_message_by_rule_idle_cb (BusDBusImpl *dbus) if (G_UNLIKELY (IBUS_OBJECT_DESTROYED (dbus))) { /* dbus was destryed */ g_mutex_lock (dbus->dispatch_lock); - g_list_foreach (dbus->dispatch_queue, (GFunc) bus_dispatch_data_free, NULL); - g_list_free (dbus->dispatch_queue); + g_list_free_full (dbus->dispatch_queue, (GDestroyNotify)bus_dispatch_data_free); dbus->dispatch_queue = NULL; g_mutex_unlock (dbus->dispatch_lock); return FALSE; /* return FALSE to prevent this callback to be called again. */ diff --git a/bus/ibusimpl.c b/bus/ibusimpl.c index d1242c85..05c7fcd9 100644 --- a/bus/ibusimpl.c +++ b/bus/ibusimpl.c @@ -417,12 +417,10 @@ bus_ibus_impl_destroy (BusIBusImpl *ibus) } } - g_list_foreach (ibus->engine_list, (GFunc) g_object_unref, NULL); - g_list_free (ibus->engine_list); + g_list_free_full (ibus->engine_list, g_object_unref); ibus->engine_list = NULL; - g_list_foreach (ibus->register_engine_list, (GFunc) g_object_unref, NULL); - g_list_free (ibus->register_engine_list); + g_list_free_full (ibus->register_engine_list, g_object_unref); ibus->register_engine_list = NULL; if (ibus->factory_dict != NULL) { diff --git a/bus/registry.c b/bus/registry.c index 7b74781f..abaab4a0 100644 --- a/bus/registry.c +++ b/bus/registry.c @@ -156,12 +156,10 @@ bus_registry_init (BusRegistry *registry) static void bus_registry_remove_all (BusRegistry *registry) { - g_list_foreach (registry->observed_paths, (GFunc) g_object_unref, NULL); - g_list_free (registry->observed_paths); + g_list_free_full (registry->observed_paths, g_object_unref); registry->observed_paths = NULL; - g_list_foreach (registry->components, (GFunc) g_object_unref, NULL); - g_list_free (registry->components); + g_list_free_full (registry->components, g_object_unref); registry->components = NULL; g_hash_table_remove_all (registry->engine_table); |