[glib] gio/*: Use g_list_free_full() convenience function
- From: Javier JardÃn <jjardon src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] gio/*: Use g_list_free_full() convenience function
- Date: Tue, 3 Jan 2012 15:54:33 +0000 (UTC)
commit 928d2cea616db45a1a0d870fd73aed2570170288
Author: Javier JardÃn <jjardon gnome org>
Date: Mon Jan 2 16:30:11 2012 +0100
gio/*: Use g_list_free_full() convenience function
gio/gcontenttype.c | 12 ++++--------
gio/gdbusauth.c | 3 +--
gio/gdbusobjectmanagerclient.c | 6 ++----
gio/gdbusobjectmanagerserver.c | 3 +--
gio/gdbusobjectskeleton.c | 3 +--
gio/gdbusserver.c | 3 +--
gio/gdesktopappinfo.c | 17 +++++------------
gio/gemblemedicon.c | 3 +--
gio/gfileenumerator.c | 3 +--
gio/gfilenamecompleter.c | 12 ++++--------
gio/gunixvolumemonitor.c | 27 +++++++++------------------
11 files changed, 30 insertions(+), 62 deletions(-)
---
diff --git a/gio/gcontenttype.c b/gio/gcontenttype.c
index ce8ab6c..b817f83 100644
--- a/gio/gcontenttype.c
+++ b/gio/gcontenttype.c
@@ -1063,8 +1063,7 @@ enumerate_mimetypes_dir (const char *dir,
* Gets a list of strings containing all the registered content types
* known to the system. The list and its data should be freed using
* <programlisting>
- * g_list_foreach (list, g_free, NULL);
- * g_list_free (list);
+ * g_list_free_full (list, g_free);
* </programlisting>
*
* Returns: (element-type utf8) (transfer full): #GList of the registered content types
@@ -1130,8 +1129,7 @@ typedef struct
static void
tree_matchlet_free (TreeMatchlet *matchlet)
{
- g_list_foreach (matchlet->matches, (GFunc)tree_matchlet_free, NULL);
- g_list_free (matchlet->matches);
+ g_list_free_full (matchlet->matches, (GDestroyNotify) tree_matchlet_free);
g_free (matchlet->path);
g_free (matchlet->mimetype);
g_slice_free (TreeMatchlet, matchlet);
@@ -1140,8 +1138,7 @@ tree_matchlet_free (TreeMatchlet *matchlet)
static void
tree_match_free (TreeMatch *match)
{
- g_list_foreach (match->matches, (GFunc)tree_matchlet_free, NULL);
- g_list_free (match->matches);
+ g_list_free_full (match->matches, (GDestroyNotify) tree_matchlet_free);
g_free (match->contenttype);
g_slice_free (TreeMatch, match);
}
@@ -1330,8 +1327,7 @@ xdg_mime_reload (void *user_data)
static void
tree_magic_shutdown (void)
{
- g_list_foreach (tree_matches, (GFunc)tree_match_free, NULL);
- g_list_free (tree_matches);
+ g_list_free_full (tree_matches, (GDestroyNotify) tree_match_free);
tree_matches = NULL;
}
diff --git a/gio/gdbusauth.c b/gio/gdbusauth.c
index 7033f29..768635b 100644
--- a/gio/gdbusauth.c
+++ b/gio/gdbusauth.c
@@ -115,8 +115,7 @@ _g_dbus_auth_finalize (GObject *object)
if (auth->priv->stream != NULL)
g_object_unref (auth->priv->stream);
- g_list_foreach (auth->priv->available_mechanisms, (GFunc) mechanism_free, NULL);
- g_list_free (auth->priv->available_mechanisms);
+ g_list_free_full (auth->priv->available_mechanisms, (GDestroyNotify) mechanism_free);
if (G_OBJECT_CLASS (_g_dbus_auth_parent_class)->finalize != NULL)
G_OBJECT_CLASS (_g_dbus_auth_parent_class)->finalize (object);
diff --git a/gio/gdbusobjectmanagerclient.c b/gio/gdbusobjectmanagerclient.c
index e6f18bf..aeff7e4 100644
--- a/gio/gdbusobjectmanagerclient.c
+++ b/gio/gdbusobjectmanagerclient.c
@@ -1252,8 +1252,7 @@ on_notify_g_name_owner (GObject *object,
GDBusObjectProxy *object_proxy = G_DBUS_OBJECT_PROXY (l->data);
g_signal_emit_by_name (manager, "object-removed", object_proxy);
}
- g_list_foreach (proxies, (GFunc) g_object_unref, NULL);
- g_list_free (proxies);
+ g_list_free_full (proxies, g_object_unref);
/* nuke local filter */
maybe_unsubscribe_signals (manager);
@@ -1573,8 +1572,7 @@ remove_interfaces (GDBusObjectManagerClient *manager,
interfaces = g_dbus_object_get_interfaces (G_DBUS_OBJECT (op));
num_interfaces = g_list_length (interfaces);
- g_list_foreach (interfaces, (GFunc) g_object_unref, NULL);
- g_list_free (interfaces);
+ g_list_free_full (interfaces, g_object_unref);
num_interfaces_to_remove = g_strv_length ((gchar **) interface_names);
diff --git a/gio/gdbusobjectmanagerserver.c b/gio/gdbusobjectmanagerserver.c
index c9a2673..cc436f8 100644
--- a/gio/gdbusobjectmanagerserver.c
+++ b/gio/gdbusobjectmanagerserver.c
@@ -497,8 +497,7 @@ g_dbus_object_manager_server_export_unlocked (GDBusObjectManagerServer *manager
registration_data_export_interface (data, interface_skeleton, object_path);
g_ptr_array_add (interface_names, g_dbus_interface_skeleton_get_info (interface_skeleton)->name);
}
- g_list_foreach (existing_interfaces, (GFunc) g_object_unref, NULL);
- g_list_free (existing_interfaces);
+ g_list_free_full (existing_interfaces, g_object_unref);
g_ptr_array_add (interface_names, NULL);
data->exported = TRUE;
diff --git a/gio/gdbusobjectskeleton.c b/gio/gdbusobjectskeleton.c
index 1f9deaf..28881e6 100644
--- a/gio/gdbusobjectskeleton.c
+++ b/gio/gdbusobjectskeleton.c
@@ -484,8 +484,7 @@ g_dbus_object_skeleton_flush (GDBusObjectSkeleton *object)
for (l = to_flush; l != NULL; l = l->next)
g_dbus_interface_skeleton_flush (G_DBUS_INTERFACE_SKELETON (l->data));
- g_list_foreach (to_flush, (GFunc) g_object_unref, NULL);
- g_list_free (to_flush);
+ g_list_free_full (to_flush, g_object_unref);
}
static void
diff --git a/gio/gdbusserver.c b/gio/gdbusserver.c
index 3fd383f..15b0856 100644
--- a/gio/gdbusserver.c
+++ b/gio/gdbusserver.c
@@ -891,8 +891,7 @@ try_tcp (GDBusServer *server,
ret = TRUE;
out:
- g_list_foreach (resolved_addresses, (GFunc) g_object_unref, NULL);
- g_list_free (resolved_addresses);
+ g_list_free_full (resolved_addresses, g_object_unref);
g_object_unref (resolver);
return ret;
}
diff --git a/gio/gdesktopappinfo.c b/gio/gdesktopappinfo.c
index 1d831ef..ee9802b 100644
--- a/gio/gdesktopappinfo.c
+++ b/gio/gdesktopappinfo.c
@@ -1312,8 +1312,7 @@ _g_desktop_app_info_launch_uris_internal (GAppInfo *appinfo,
envp = g_environ_setenv (envp, "DESKTOP_STARTUP_ID", sn_id, TRUE);
}
- g_list_foreach (launched_files, (GFunc)g_object_unref, NULL);
- g_list_free (launched_files);
+ g_list_free_full (launched_files, g_object_unref);
}
if (!g_spawn_async (info->path,
@@ -1431,8 +1430,7 @@ g_desktop_app_info_launch (GAppInfo *appinfo,
res = g_desktop_app_info_launch_uris (appinfo, uris, launch_context, error);
- g_list_foreach (uris, (GFunc)g_free, NULL);
- g_list_free (uris);
+ g_list_free_full (uris, g_free);
return res;
}
@@ -2628,8 +2626,7 @@ destroy_info_cache_value (gpointer key,
GList *value,
gpointer data)
{
- g_list_foreach (value, (GFunc)g_free, NULL);
- g_list_free (value);
+ g_list_free_full (value, g_free);
}
static void
@@ -3147,10 +3144,7 @@ mime_info_cache_free (MimeInfoCache *cache)
if (cache == NULL)
return;
- g_list_foreach (cache->dirs,
- (GFunc) mime_info_cache_dir_free,
- NULL);
- g_list_free (cache->dirs);
+ g_list_free_full (cache->dirs, (GDestroyNotify) mime_info_cache_dir_free);
g_hash_table_destroy (cache->global_defaults_cache);
g_free (cache);
}
@@ -3345,8 +3339,7 @@ get_all_desktop_entries_for_mime_type (const char *base_mime_type,
else
g_free (default_entry);
- g_list_foreach (removed_entries, (GFunc)g_free, NULL);
- g_list_free (removed_entries);
+ g_list_free_full (removed_entries, g_free);
desktop_entries = g_list_reverse (desktop_entries);
diff --git a/gio/gemblemedicon.c b/gio/gemblemedicon.c
index 6f7af0e..b02ec44 100644
--- a/gio/gemblemedicon.c
+++ b/gio/gemblemedicon.c
@@ -73,8 +73,7 @@ g_emblemed_icon_finalize (GObject *object)
emblemed = G_EMBLEMED_ICON (object);
g_object_unref (emblemed->priv->icon);
- g_list_foreach (emblemed->priv->emblems, (GFunc) g_object_unref, NULL);
- g_list_free (emblemed->priv->emblems);
+ g_list_free_full (emblemed->priv->emblems, g_object_unref);
(*G_OBJECT_CLASS (g_emblemed_icon_parent_class)->finalize) (object);
}
diff --git a/gio/gfileenumerator.c b/gio/gfileenumerator.c
index ef9d56a..654c691 100644
--- a/gio/gfileenumerator.c
+++ b/gio/gfileenumerator.c
@@ -607,8 +607,7 @@ static void
next_async_op_free (NextAsyncOp *op)
{
/* Free the list, if finish wasn't called */
- g_list_foreach (op->files, (GFunc)g_object_unref, NULL);
- g_list_free (op->files);
+ g_list_free_full (op->files, g_object_unref);
g_free (op);
}
diff --git a/gio/gfilenamecompleter.c b/gio/gfilenamecompleter.c
index fc9afeb..f841c16 100644
--- a/gio/gfilenamecompleter.c
+++ b/gio/gfilenamecompleter.c
@@ -86,8 +86,7 @@ g_filename_completer_finalize (GObject *object)
if (completer->basenames_dir)
g_object_unref (completer->basenames_dir);
- g_list_foreach (completer->basenames, (GFunc)g_free, NULL);
- g_list_free (completer->basenames);
+ g_list_free_full (completer->basenames, g_free);
G_OBJECT_CLASS (g_filename_completer_parent_class)->finalize (object);
}
@@ -155,8 +154,7 @@ load_basenames_data_free (LoadBasenamesData *data)
g_object_unref (data->cancellable);
g_object_unref (data->dir);
- g_list_foreach (data->basenames, (GFunc)g_free, NULL);
- g_list_free (data->basenames);
+ g_list_free_full (data->basenames, g_free);
g_free (data);
}
@@ -243,8 +241,7 @@ got_more_files (GObject *source_object,
if (data->completer->basenames_dir)
g_object_unref (data->completer->basenames_dir);
- g_list_foreach (data->completer->basenames, (GFunc)g_free, NULL);
- g_list_free (data->completer->basenames);
+ g_list_free_full (data->completer->basenames, g_free);
data->completer->basenames_dir = g_object_ref (data->dir);
data->completer->basenames = data->basenames;
@@ -281,8 +278,7 @@ got_enum (GObject *source_object,
if (data->completer->basenames_dir)
g_object_unref (data->completer->basenames_dir);
- g_list_foreach (data->completer->basenames, (GFunc)g_free, NULL);
- g_list_free (data->completer->basenames);
+ g_list_free_full (data->completer->basenames, g_free);
/* Mark uptodate with no basenames */
data->completer->basenames_dir = g_object_ref (data->dir);
diff --git a/gio/gunixvolumemonitor.c b/gio/gunixvolumemonitor.c
index 76a9840..26ec483 100644
--- a/gio/gunixvolumemonitor.c
+++ b/gio/gunixvolumemonitor.c
@@ -76,15 +76,11 @@ g_unix_volume_monitor_finalize (GObject *object)
g_object_unref (monitor->mount_monitor);
- g_list_foreach (monitor->last_mountpoints, (GFunc)g_unix_mount_point_free, NULL);
- g_list_free (monitor->last_mountpoints);
- g_list_foreach (monitor->last_mounts, (GFunc)g_unix_mount_free, NULL);
- g_list_free (monitor->last_mounts);
+ g_list_free_full (monitor->last_mountpoints, (GDestroyNotify) g_unix_mount_point_free);
+ g_list_free_full (monitor->last_mounts, (GDestroyNotify) g_unix_mount_free);
- g_list_foreach (monitor->volumes, (GFunc)g_object_unref, NULL);
- g_list_free (monitor->volumes);
- g_list_foreach (monitor->mounts, (GFunc)g_object_unref, NULL);
- g_list_free (monitor->mounts);
+ g_list_free_full (monitor->volumes, g_object_unref);
+ g_list_free_full (monitor->mounts, g_object_unref);
G_OBJECT_CLASS (g_unix_volume_monitor_parent_class)->finalize (object);
}
@@ -95,12 +91,11 @@ g_unix_volume_monitor_dispose (GObject *object)
GUnixVolumeMonitor *monitor;
monitor = G_UNIX_VOLUME_MONITOR (object);
- g_list_foreach (monitor->volumes, (GFunc)g_object_unref, NULL);
- g_list_free (monitor->volumes);
+
+ g_list_free_full (monitor->volumes, g_object_unref);
monitor->volumes = NULL;
- g_list_foreach (monitor->mounts, (GFunc)g_object_unref, NULL);
- g_list_free (monitor->mounts);
+ g_list_free_full (monitor->mounts, g_object_unref);
monitor->mounts = NULL;
G_OBJECT_CLASS (g_unix_volume_monitor_parent_class)->dispose (object);
@@ -372,9 +367,7 @@ update_volumes (GUnixVolumeMonitor *monitor)
g_list_free (added);
g_list_free (removed);
- g_list_foreach (monitor->last_mountpoints,
- (GFunc)g_unix_mount_point_free, NULL);
- g_list_free (monitor->last_mountpoints);
+ g_list_free_full (monitor->last_mountpoints, (GDestroyNotify) g_unix_mount_point_free);
monitor->last_mountpoints = new_mountpoints;
}
@@ -428,8 +421,6 @@ update_mounts (GUnixVolumeMonitor *monitor)
g_list_free (added);
g_list_free (removed);
- g_list_foreach (monitor->last_mounts,
- (GFunc)g_unix_mount_free, NULL);
- g_list_free (monitor->last_mounts);
+ g_list_free_full (monitor->last_mounts, (GDestroyNotify) g_unix_mount_free);
monitor->last_mounts = new_mounts;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]