gio/*: Use g_list_free_full() convenience function

This commit is contained in:
Javier Jardón 2012-01-02 16:30:11 +01:00
parent dde3401122
commit 928d2cea61
11 changed files with 30 additions and 62 deletions

View File

@ -1063,8 +1063,7 @@ enumerate_mimetypes_dir (const char *dir,
* Gets a list of strings containing all the registered content types * Gets a list of strings containing all the registered content types
* known to the system. The list and its data should be freed using * known to the system. The list and its data should be freed using
* <programlisting> * <programlisting>
* g_list_foreach (list, g_free, NULL); * g_list_free_full (list, g_free);
* g_list_free (list);
* </programlisting> * </programlisting>
* *
* Returns: (element-type utf8) (transfer full): #GList of the registered content types * Returns: (element-type utf8) (transfer full): #GList of the registered content types
@ -1130,8 +1129,7 @@ typedef struct
static void static void
tree_matchlet_free (TreeMatchlet *matchlet) tree_matchlet_free (TreeMatchlet *matchlet)
{ {
g_list_foreach (matchlet->matches, (GFunc)tree_matchlet_free, NULL); g_list_free_full (matchlet->matches, (GDestroyNotify) tree_matchlet_free);
g_list_free (matchlet->matches);
g_free (matchlet->path); g_free (matchlet->path);
g_free (matchlet->mimetype); g_free (matchlet->mimetype);
g_slice_free (TreeMatchlet, matchlet); g_slice_free (TreeMatchlet, matchlet);
@ -1140,8 +1138,7 @@ tree_matchlet_free (TreeMatchlet *matchlet)
static void static void
tree_match_free (TreeMatch *match) tree_match_free (TreeMatch *match)
{ {
g_list_foreach (match->matches, (GFunc)tree_matchlet_free, NULL); g_list_free_full (match->matches, (GDestroyNotify) tree_matchlet_free);
g_list_free (match->matches);
g_free (match->contenttype); g_free (match->contenttype);
g_slice_free (TreeMatch, match); g_slice_free (TreeMatch, match);
} }
@ -1330,8 +1327,7 @@ xdg_mime_reload (void *user_data)
static void static void
tree_magic_shutdown (void) tree_magic_shutdown (void)
{ {
g_list_foreach (tree_matches, (GFunc)tree_match_free, NULL); g_list_free_full (tree_matches, (GDestroyNotify) tree_match_free);
g_list_free (tree_matches);
tree_matches = NULL; tree_matches = NULL;
} }

View File

@ -115,8 +115,7 @@ _g_dbus_auth_finalize (GObject *object)
if (auth->priv->stream != NULL) if (auth->priv->stream != NULL)
g_object_unref (auth->priv->stream); g_object_unref (auth->priv->stream);
g_list_foreach (auth->priv->available_mechanisms, (GFunc) mechanism_free, NULL); g_list_free_full (auth->priv->available_mechanisms, (GDestroyNotify) mechanism_free);
g_list_free (auth->priv->available_mechanisms);
if (G_OBJECT_CLASS (_g_dbus_auth_parent_class)->finalize != NULL) if (G_OBJECT_CLASS (_g_dbus_auth_parent_class)->finalize != NULL)
G_OBJECT_CLASS (_g_dbus_auth_parent_class)->finalize (object); G_OBJECT_CLASS (_g_dbus_auth_parent_class)->finalize (object);

View File

@ -1252,8 +1252,7 @@ on_notify_g_name_owner (GObject *object,
GDBusObjectProxy *object_proxy = G_DBUS_OBJECT_PROXY (l->data); GDBusObjectProxy *object_proxy = G_DBUS_OBJECT_PROXY (l->data);
g_signal_emit_by_name (manager, "object-removed", object_proxy); g_signal_emit_by_name (manager, "object-removed", object_proxy);
} }
g_list_foreach (proxies, (GFunc) g_object_unref, NULL); g_list_free_full (proxies, g_object_unref);
g_list_free (proxies);
/* nuke local filter */ /* nuke local filter */
maybe_unsubscribe_signals (manager); maybe_unsubscribe_signals (manager);
@ -1573,8 +1572,7 @@ remove_interfaces (GDBusObjectManagerClient *manager,
interfaces = g_dbus_object_get_interfaces (G_DBUS_OBJECT (op)); interfaces = g_dbus_object_get_interfaces (G_DBUS_OBJECT (op));
num_interfaces = g_list_length (interfaces); num_interfaces = g_list_length (interfaces);
g_list_foreach (interfaces, (GFunc) g_object_unref, NULL); g_list_free_full (interfaces, g_object_unref);
g_list_free (interfaces);
num_interfaces_to_remove = g_strv_length ((gchar **) interface_names); num_interfaces_to_remove = g_strv_length ((gchar **) interface_names);

View File

@ -497,8 +497,7 @@ g_dbus_object_manager_server_export_unlocked (GDBusObjectManagerServer *manager
registration_data_export_interface (data, interface_skeleton, object_path); 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_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_full (existing_interfaces, g_object_unref);
g_list_free (existing_interfaces);
g_ptr_array_add (interface_names, NULL); g_ptr_array_add (interface_names, NULL);
data->exported = TRUE; data->exported = TRUE;

View File

@ -484,8 +484,7 @@ g_dbus_object_skeleton_flush (GDBusObjectSkeleton *object)
for (l = to_flush; l != NULL; l = l->next) for (l = to_flush; l != NULL; l = l->next)
g_dbus_interface_skeleton_flush (G_DBUS_INTERFACE_SKELETON (l->data)); g_dbus_interface_skeleton_flush (G_DBUS_INTERFACE_SKELETON (l->data));
g_list_foreach (to_flush, (GFunc) g_object_unref, NULL); g_list_free_full (to_flush, g_object_unref);
g_list_free (to_flush);
} }
static void static void

View File

@ -891,8 +891,7 @@ try_tcp (GDBusServer *server,
ret = TRUE; ret = TRUE;
out: out:
g_list_foreach (resolved_addresses, (GFunc) g_object_unref, NULL); g_list_free_full (resolved_addresses, g_object_unref);
g_list_free (resolved_addresses);
g_object_unref (resolver); g_object_unref (resolver);
return ret; return ret;
} }

View File

@ -1312,8 +1312,7 @@ _g_desktop_app_info_launch_uris_internal (GAppInfo *appinfo,
envp = g_environ_setenv (envp, "DESKTOP_STARTUP_ID", sn_id, TRUE); envp = g_environ_setenv (envp, "DESKTOP_STARTUP_ID", sn_id, TRUE);
} }
g_list_foreach (launched_files, (GFunc)g_object_unref, NULL); g_list_free_full (launched_files, g_object_unref);
g_list_free (launched_files);
} }
if (!g_spawn_async (info->path, 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); res = g_desktop_app_info_launch_uris (appinfo, uris, launch_context, error);
g_list_foreach (uris, (GFunc)g_free, NULL); g_list_free_full (uris, g_free);
g_list_free (uris);
return res; return res;
} }
@ -2628,8 +2626,7 @@ destroy_info_cache_value (gpointer key,
GList *value, GList *value,
gpointer data) gpointer data)
{ {
g_list_foreach (value, (GFunc)g_free, NULL); g_list_free_full (value, g_free);
g_list_free (value);
} }
static void static void
@ -3147,10 +3144,7 @@ mime_info_cache_free (MimeInfoCache *cache)
if (cache == NULL) if (cache == NULL)
return; return;
g_list_foreach (cache->dirs, g_list_free_full (cache->dirs, (GDestroyNotify) mime_info_cache_dir_free);
(GFunc) mime_info_cache_dir_free,
NULL);
g_list_free (cache->dirs);
g_hash_table_destroy (cache->global_defaults_cache); g_hash_table_destroy (cache->global_defaults_cache);
g_free (cache); g_free (cache);
} }
@ -3345,8 +3339,7 @@ get_all_desktop_entries_for_mime_type (const char *base_mime_type,
else else
g_free (default_entry); g_free (default_entry);
g_list_foreach (removed_entries, (GFunc)g_free, NULL); g_list_free_full (removed_entries, g_free);
g_list_free (removed_entries);
desktop_entries = g_list_reverse (desktop_entries); desktop_entries = g_list_reverse (desktop_entries);

View File

@ -73,8 +73,7 @@ g_emblemed_icon_finalize (GObject *object)
emblemed = G_EMBLEMED_ICON (object); emblemed = G_EMBLEMED_ICON (object);
g_object_unref (emblemed->priv->icon); g_object_unref (emblemed->priv->icon);
g_list_foreach (emblemed->priv->emblems, (GFunc) g_object_unref, NULL); g_list_free_full (emblemed->priv->emblems, g_object_unref);
g_list_free (emblemed->priv->emblems);
(*G_OBJECT_CLASS (g_emblemed_icon_parent_class)->finalize) (object); (*G_OBJECT_CLASS (g_emblemed_icon_parent_class)->finalize) (object);
} }

View File

@ -607,8 +607,7 @@ static void
next_async_op_free (NextAsyncOp *op) next_async_op_free (NextAsyncOp *op)
{ {
/* Free the list, if finish wasn't called */ /* Free the list, if finish wasn't called */
g_list_foreach (op->files, (GFunc)g_object_unref, NULL); g_list_free_full (op->files, g_object_unref);
g_list_free (op->files);
g_free (op); g_free (op);
} }

View File

@ -86,8 +86,7 @@ g_filename_completer_finalize (GObject *object)
if (completer->basenames_dir) if (completer->basenames_dir)
g_object_unref (completer->basenames_dir); g_object_unref (completer->basenames_dir);
g_list_foreach (completer->basenames, (GFunc)g_free, NULL); g_list_free_full (completer->basenames, g_free);
g_list_free (completer->basenames);
G_OBJECT_CLASS (g_filename_completer_parent_class)->finalize (object); 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->cancellable);
g_object_unref (data->dir); g_object_unref (data->dir);
g_list_foreach (data->basenames, (GFunc)g_free, NULL); g_list_free_full (data->basenames, g_free);
g_list_free (data->basenames);
g_free (data); g_free (data);
} }
@ -243,8 +241,7 @@ got_more_files (GObject *source_object,
if (data->completer->basenames_dir) if (data->completer->basenames_dir)
g_object_unref (data->completer->basenames_dir); g_object_unref (data->completer->basenames_dir);
g_list_foreach (data->completer->basenames, (GFunc)g_free, NULL); g_list_free_full (data->completer->basenames, g_free);
g_list_free (data->completer->basenames);
data->completer->basenames_dir = g_object_ref (data->dir); data->completer->basenames_dir = g_object_ref (data->dir);
data->completer->basenames = data->basenames; data->completer->basenames = data->basenames;
@ -281,8 +278,7 @@ got_enum (GObject *source_object,
if (data->completer->basenames_dir) if (data->completer->basenames_dir)
g_object_unref (data->completer->basenames_dir); g_object_unref (data->completer->basenames_dir);
g_list_foreach (data->completer->basenames, (GFunc)g_free, NULL); g_list_free_full (data->completer->basenames, g_free);
g_list_free (data->completer->basenames);
/* Mark uptodate with no basenames */ /* Mark uptodate with no basenames */
data->completer->basenames_dir = g_object_ref (data->dir); data->completer->basenames_dir = g_object_ref (data->dir);

View File

@ -76,15 +76,11 @@ g_unix_volume_monitor_finalize (GObject *object)
g_object_unref (monitor->mount_monitor); g_object_unref (monitor->mount_monitor);
g_list_foreach (monitor->last_mountpoints, (GFunc)g_unix_mount_point_free, NULL); g_list_free_full (monitor->last_mountpoints, (GDestroyNotify) g_unix_mount_point_free);
g_list_free (monitor->last_mountpoints); g_list_free_full (monitor->last_mounts, (GDestroyNotify) g_unix_mount_free);
g_list_foreach (monitor->last_mounts, (GFunc)g_unix_mount_free, NULL);
g_list_free (monitor->last_mounts);
g_list_foreach (monitor->volumes, (GFunc)g_object_unref, NULL); g_list_free_full (monitor->volumes, g_object_unref);
g_list_free (monitor->volumes); g_list_free_full (monitor->mounts, g_object_unref);
g_list_foreach (monitor->mounts, (GFunc)g_object_unref, NULL);
g_list_free (monitor->mounts);
G_OBJECT_CLASS (g_unix_volume_monitor_parent_class)->finalize (object); G_OBJECT_CLASS (g_unix_volume_monitor_parent_class)->finalize (object);
} }
@ -95,12 +91,11 @@ g_unix_volume_monitor_dispose (GObject *object)
GUnixVolumeMonitor *monitor; GUnixVolumeMonitor *monitor;
monitor = G_UNIX_VOLUME_MONITOR (object); 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; monitor->volumes = NULL;
g_list_foreach (monitor->mounts, (GFunc)g_object_unref, NULL); g_list_free_full (monitor->mounts, g_object_unref);
g_list_free (monitor->mounts);
monitor->mounts = NULL; monitor->mounts = NULL;
G_OBJECT_CLASS (g_unix_volume_monitor_parent_class)->dispose (object); 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 (added);
g_list_free (removed); g_list_free (removed);
g_list_foreach (monitor->last_mountpoints, g_list_free_full (monitor->last_mountpoints, (GDestroyNotify) g_unix_mount_point_free);
(GFunc)g_unix_mount_point_free, NULL);
g_list_free (monitor->last_mountpoints);
monitor->last_mountpoints = new_mountpoints; monitor->last_mountpoints = new_mountpoints;
} }
@ -428,8 +421,6 @@ update_mounts (GUnixVolumeMonitor *monitor)
g_list_free (added); g_list_free (added);
g_list_free (removed); g_list_free (removed);
g_list_foreach (monitor->last_mounts, g_list_free_full (monitor->last_mounts, (GDestroyNotify) g_unix_mount_free);
(GFunc)g_unix_mount_free, NULL);
g_list_free (monitor->last_mounts);
monitor->last_mounts = new_mounts; monitor->last_mounts = new_mounts;
} }