[gvfs] Use g_list_free_full() where applicable
- From: Tomas Bzatek <tbzatek src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gvfs] Use g_list_free_full() where applicable
- Date: Thu, 17 Jan 2013 10:59:04 +0000 (UTC)
commit fd135fe90ce9b9a568468c4ddb21e6d13135e80d
Author: Tomas Bzatek <tbzatek redhat com>
Date: Thu Jan 17 11:57:43 2013 +0100
Use g_list_free_full() where applicable
client/gdaemonfileenumerator.c | 3 +-
client/gdaemonvfs.c | 3 +-
client/gdaemonvolumemonitor.c | 3 +-
client/gvfsfusedaemon.c | 3 +-
common/gmounttracker.c | 4 +-
common/gvfsmountinfo.c | 3 +-
daemon/gvfsbackendarchive.c | 3 +-
daemon/gvfsbackendcdda.c | 6 +--
daemon/gvfsbackendcomputer.c | 3 +-
daemon/gvfsbackenddnssd.c | 2 +-
daemon/gvfsbackendftp.c | 3 +-
daemon/gvfsbackendgphoto2.c | 15 ++-----
daemon/gvfsbackendobexftp-cap-parser.c | 5 +--
daemon/gvfsbackendobexftp-fl-parser.c | 3 +-
daemon/gvfsbackendobexftp.c | 9 +---
daemon/gvfsbackendsmb.c | 3 +-
daemon/gvfsbackendsmbbrowse.c | 9 +---
daemon/mount.c | 3 +-
metadata/metabuilder.c | 20 +++-------
monitor/afc/afcvolumemonitor.c | 9 +----
monitor/gphoto2/ggphoto2volumemonitor.c | 27 ++++--------
monitor/proxy/gproxyvolume.c | 3 +-
monitor/proxy/gvfsproxyvolumemonitordaemon.c | 45 +++++----------------
monitor/udisks2/gvfsudisks2volumemonitor.c | 55 +++++++++-----------------
programs/gvfs-mount.c | 18 +++------
25 files changed, 80 insertions(+), 180 deletions(-)
---
diff --git a/client/gdaemonfileenumerator.c b/client/gdaemonfileenumerator.c
index f8cdcc9..0c3c697 100644
--- a/client/gdaemonfileenumerator.c
+++ b/client/gdaemonfileenumerator.c
@@ -97,8 +97,7 @@ static void trigger_async_done (GDaemonFileEnumerator *daemon, gboo
static void
free_info_list (GList *infos)
{
- g_list_foreach (infos, (GFunc)g_object_unref, NULL);
- g_list_free (infos);
+ g_list_free_full (infos, g_object_unref);
}
static void
diff --git a/client/gdaemonvfs.c b/client/gdaemonvfs.c
index 3ca31a2..b712b22 100644
--- a/client/gdaemonvfs.c
+++ b/client/gdaemonvfs.c
@@ -349,8 +349,7 @@ g_daemon_vfs_init (GDaemonVfs *vfs)
}
/* The above should have ref:ed the modules anyway */
- g_list_foreach (modules, (GFunc)g_type_module_unuse, NULL);
- g_list_free (modules);
+ g_list_free_full (modules, (GDestroyNotify)g_type_module_unuse);
g_free (mappers);
}
diff --git a/client/gdaemonvolumemonitor.c b/client/gdaemonvolumemonitor.c
index af381a6..b73453b 100644
--- a/client/gdaemonvolumemonitor.c
+++ b/client/gdaemonvolumemonitor.c
@@ -239,8 +239,7 @@ g_daemon_volume_monitor_finalize (GObject *object)
g_object_unref (monitor->mount_tracker);
- g_list_foreach (monitor->mounts, (GFunc)g_object_unref, NULL);
- g_list_free (monitor->mounts);
+ g_list_free_full (monitor->mounts, g_object_unref);
if (G_OBJECT_CLASS (g_daemon_volume_monitor_parent_class)->finalize)
(*G_OBJECT_CLASS (g_daemon_volume_monitor_parent_class)->finalize) (object);
diff --git a/client/gvfsfusedaemon.c b/client/gvfsfusedaemon.c
index 6bb21e7..6ce5133 100644
--- a/client/gvfsfusedaemon.c
+++ b/client/gvfsfusedaemon.c
@@ -408,8 +408,7 @@ mount_list_unlock (void)
static void
mount_list_free (void)
{
- g_list_foreach (mount_list, (GFunc) mount_record_free, NULL);
- g_list_free (mount_list);
+ g_list_free_full (mount_list, (GDestroyNotify) mount_record_free);
mount_list = NULL;
}
diff --git a/common/gmounttracker.c b/common/gmounttracker.c
index 90b2622..2356fe4 100644
--- a/common/gmounttracker.c
+++ b/common/gmounttracker.c
@@ -267,9 +267,7 @@ g_mount_tracker_finalize (GObject *object)
g_mutex_clear (&tracker->lock);
- g_list_foreach (tracker->mounts,
- (GFunc)g_mount_info_unref, NULL);
- g_list_free (tracker->mounts);
+ g_list_free_full (tracker->mounts, (GDestroyNotify)g_mount_info_unref);
g_clear_object (&tracker->proxy);
g_clear_object (&tracker->connection);
diff --git a/common/gvfsmountinfo.c b/common/gvfsmountinfo.c
index cea2be4..756bbd0 100644
--- a/common/gvfsmountinfo.c
+++ b/common/gvfsmountinfo.c
@@ -834,8 +834,7 @@ more_files_callback (GObject *source_object, GAsyncResult *res,
break;
}
- g_list_foreach (files, (GFunc)g_object_unref, NULL);
- g_list_free (files);
+ g_list_free_full (files, g_object_unref);
g_free (name_collation_key);
if (filename)
diff --git a/daemon/gvfsbackendarchive.c b/daemon/gvfsbackendarchive.c
index 30b4455..1babced 100644
--- a/daemon/gvfsbackendarchive.c
+++ b/daemon/gvfsbackendarchive.c
@@ -513,8 +513,7 @@ create_file_tree (GVfsBackendArchive *ba, GVfsJob *job)
static void
archive_file_free (ArchiveFile *file)
{
- g_slist_foreach (file->children, (GFunc) archive_file_free, NULL);
- g_slist_free (file->children);
+ g_slist_free_full (file->children, (GDestroyNotify) archive_file_free);
if (file->info)
g_object_unref (file->info);
g_free (file->name);
diff --git a/daemon/gvfsbackendcdda.c b/daemon/gvfsbackendcdda.c
index 837d103..88f70fb 100644
--- a/daemon/gvfsbackendcdda.c
+++ b/daemon/gvfsbackendcdda.c
@@ -150,8 +150,7 @@ release_metadata (GVfsBackendCdda *cdda_backend)
cdda_backend->album_artist = NULL;
g_free (cdda_backend->genre);
cdda_backend->genre = NULL;
- g_list_foreach (cdda_backend->tracks, (GFunc) track_free, NULL);
- g_list_free (cdda_backend->tracks);
+ g_list_free_full (cdda_backend->tracks, (GDestroyNotify) track_free);
cdda_backend->tracks = NULL;
}
@@ -1066,8 +1065,7 @@ do_enumerate (GVfsBackend *backend,
g_vfs_job_succeeded (G_VFS_JOB (job));
g_vfs_job_enumerate_add_infos (job, l);
- g_list_foreach (l, (GFunc) g_object_unref, NULL);
- g_list_free (l);
+ g_list_free_full (l, g_object_unref);
g_vfs_job_enumerate_done (job);
}
diff --git a/daemon/gvfsbackendcomputer.c b/daemon/gvfsbackendcomputer.c
index e79454f..a5879e7 100644
--- a/daemon/gvfsbackendcomputer.c
+++ b/daemon/gvfsbackendcomputer.c
@@ -889,8 +889,7 @@ mount_volume_from_drive (GDrive *drive,
_("Can't mount file"));
}
- g_list_foreach (volumes, (GFunc)g_object_unref, NULL);
- g_list_free (volumes);
+ g_list_free_full (volumes, g_object_unref);
}
static void
diff --git a/daemon/gvfsbackenddnssd.c b/daemon/gvfsbackenddnssd.c
index 8198604..366b299 100644
--- a/daemon/gvfsbackenddnssd.c
+++ b/daemon/gvfsbackenddnssd.c
@@ -800,7 +800,7 @@ g_vfs_backend_dns_sd_finalize (GObject *object)
g_free (backend->domain);
- g_list_foreach (backend->files, (GFunc)link_file_free, NULL);
+ g_list_free_full (backend->files, (GDestroyNotify)link_file_free);
if (G_OBJECT_CLASS (g_vfs_backend_dns_sd_parent_class)->finalize)
(*G_OBJECT_CLASS (g_vfs_backend_dns_sd_parent_class)->finalize) (object);
diff --git a/daemon/gvfsbackendftp.c b/daemon/gvfsbackendftp.c
index c55640e..8edb448 100644
--- a/daemon/gvfsbackendftp.c
+++ b/daemon/gvfsbackendftp.c
@@ -1269,8 +1269,7 @@ do_delete (GVfsBackend *backend,
G_IO_ERROR,
G_IO_ERROR_NOT_EMPTY,
g_strerror (ENOTEMPTY));
- g_list_foreach (list, (GFunc) g_object_unref, NULL);
- g_list_free (list);
+ g_list_free_full (list, g_object_unref);
}
else
{
diff --git a/daemon/gvfsbackendgphoto2.c b/daemon/gvfsbackendgphoto2.c
index 0bf346a..19f3c34 100644
--- a/daemon/gvfsbackendgphoto2.c
+++ b/daemon/gvfsbackendgphoto2.c
@@ -2227,8 +2227,7 @@ do_enumerate (GVfsBackend *backend,
{
g_vfs_job_failed_from_error (G_VFS_JOB (job), error);
g_error_free (error);
- g_list_foreach (l, (GFunc) g_object_unref, NULL);
- g_list_free (l);
+ g_list_free_full (l, g_object_unref);
gp_list_free (list);
return;
}
@@ -2294,8 +2293,7 @@ do_enumerate (GVfsBackend *backend,
{
g_vfs_job_failed_from_error (G_VFS_JOB (job), error);
g_error_free (error);
- g_list_foreach (l, (GFunc) g_object_unref, NULL);
- g_list_free (l);
+ g_list_free_full (l, g_object_unref);
gp_list_free (list);
return;
}
@@ -2320,8 +2318,7 @@ do_enumerate (GVfsBackend *backend,
g_vfs_job_succeeded (G_VFS_JOB (job));
g_vfs_job_enumerate_add_infos (job, l);
- g_list_foreach (l, (GFunc) g_object_unref, NULL);
- g_list_free (l);
+ g_list_free_full (l, g_object_unref);
g_vfs_job_enumerate_done (job);
g_free (filename);
@@ -2411,8 +2408,7 @@ try_enumerate (GVfsBackend *backend,
g_vfs_job_succeeded (G_VFS_JOB (job));
g_vfs_job_enumerate_add_infos (job, l);
- g_list_foreach (l, (GFunc) g_object_unref, NULL);
- g_list_free (l);
+ g_list_free_full (l, g_object_unref);
g_vfs_job_enumerate_done (job);
g_free (filename);
@@ -2420,8 +2416,7 @@ try_enumerate (GVfsBackend *backend,
return TRUE;
error_not_cached:
- g_list_foreach (l, (GFunc) g_object_unref, NULL);
- g_list_free (l);
+ g_list_free_full (l, g_object_unref);
g_free (filename);
DEBUG (" BUU no info from cache for try_enumerate (%s)", given_filename);
diff --git a/daemon/gvfsbackendobexftp-cap-parser.c b/daemon/gvfsbackendobexftp-cap-parser.c
index 804467d..4629930 100644
--- a/daemon/gvfsbackendobexftp-cap-parser.c
+++ b/daemon/gvfsbackendobexftp-cap-parser.c
@@ -523,10 +523,7 @@ ovu_caps_memory_equal (OvuCapsMemory *m1, OvuCapsMemory *m2)
void
ovu_caps_free (OvuCaps *caps)
{
- g_list_foreach (caps->memory_entries,
- (GFunc) ovu_caps_memory_free, NULL);
-
- g_list_free (caps->memory_entries);
+ g_list_free_full (caps->memory_entries, (GDestroyNotify) ovu_caps_memory_free);
g_free (caps);
}
diff --git a/daemon/gvfsbackendobexftp-fl-parser.c b/daemon/gvfsbackendobexftp-fl-parser.c
index 5aca2ad..5e97a91 100644
--- a/daemon/gvfsbackendobexftp-fl-parser.c
+++ b/daemon/gvfsbackendobexftp-fl-parser.c
@@ -350,8 +350,7 @@ static void
fl_parser_free_parser_data (ParserData *data, gboolean free_list)
{
if (free_list) {
- g_list_foreach (data->elements, (GFunc) g_object_unref, NULL);
- g_list_free (data->elements);
+ g_list_free_full (data->elements, g_object_unref);
data->elements = NULL;
}
diff --git a/daemon/gvfsbackendobexftp.c b/daemon/gvfsbackendobexftp.c
index 69e3267..242250c 100644
--- a/daemon/gvfsbackendobexftp.c
+++ b/daemon/gvfsbackendobexftp.c
@@ -752,8 +752,7 @@ _query_file_info_helper (GVfsBackend *backend,
}
g_free (basename);
- g_list_foreach (elements, (GFunc)g_object_unref, NULL);
- g_list_free (elements);
+ g_list_free_full (elements, g_object_unref);
g_debug ("- _query_file_info_helper\n");
@@ -1547,8 +1546,7 @@ do_enumerate (GVfsBackend *backend,
g_vfs_job_enumerate_add_infos (job, elements);
- g_list_foreach (elements, (GFunc)g_object_unref, NULL);
- g_list_free (elements);
+ g_list_free_full (elements, g_object_unref);
g_vfs_job_enumerate_done (job);
g_mutex_unlock (&op_backend->mutex);
@@ -1972,8 +1970,7 @@ do_delete (GVfsBackend *backend,
g_free (files);
len = g_list_length (elements);
- g_list_foreach (elements, (GFunc)g_object_unref, NULL);
- g_list_free (elements);
+ g_list_free_full (elements, g_object_unref);
if (len != 0)
{
diff --git a/daemon/gvfsbackendsmb.c b/daemon/gvfsbackendsmb.c
index f69bc1b..0f6f089 100644
--- a/daemon/gvfsbackendsmb.c
+++ b/daemon/gvfsbackendsmb.c
@@ -1888,8 +1888,7 @@ do_enumerate (GVfsBackend *backend,
{
files = g_list_reverse (files);
g_vfs_job_enumerate_add_infos (job, files);
- g_list_foreach (files, (GFunc)g_object_unref, NULL);
- g_list_free (files);
+ g_list_free_full (files, g_object_unref);
}
}
diff --git a/daemon/gvfsbackendsmbbrowse.c b/daemon/gvfsbackendsmbbrowse.c
index f216fa6..46bbc94 100644
--- a/daemon/gvfsbackendsmbbrowse.c
+++ b/daemon/gvfsbackendsmbbrowse.c
@@ -231,8 +231,7 @@ g_vfs_backend_smb_browse_finalize (GObject *object)
smbc_free_context (backend->smb_context, TRUE);
- g_list_foreach (backend->entries, (GFunc)browse_entry_free, NULL);
- g_list_free (backend->entries);
+ g_list_free_full (backend->entries, (GDestroyNotify)browse_entry_free);
if (G_OBJECT_CLASS (g_vfs_backend_smb_browse_parent_class)->finalize)
(*G_OBJECT_CLASS (g_vfs_backend_smb_browse_parent_class)->finalize) (object);
@@ -668,8 +667,7 @@ update_cache (GVfsBackendSmbBrowse *backend, SMBCFILE *supplied_dir)
g_mutex_lock (&backend->entries_lock);
/* Clear old cache */
- g_list_foreach (backend->entries, (GFunc)browse_entry_free, NULL);
- g_list_free (backend->entries);
+ g_list_free_full (backend->entries, (GDestroyNotify)browse_entry_free);
backend->entries = entries;
backend->entry_errno = entry_errno;
backend->last_entry_update = time (NULL);
@@ -1447,8 +1445,7 @@ run_enumerate (GVfsBackendSmbBrowse *backend,
files = g_list_reverse (files);
g_vfs_job_enumerate_add_infos (job, files);
- g_list_foreach (files, (GFunc)g_object_unref, NULL);
- g_list_free (files);
+ g_list_free_full (files, g_object_unref);
g_vfs_job_enumerate_done (job);
}
diff --git a/daemon/mount.c b/daemon/mount.c
index 5224a66..d1341f5 100644
--- a/daemon/mount.c
+++ b/daemon/mount.c
@@ -547,8 +547,7 @@ read_mountable_config (void)
static void
re_read_mountable_config (void)
{
- g_list_foreach (mountables, (GFunc)vfs_mountable_free, NULL);
- g_list_free (mountables);
+ g_list_free_full (mountables, (GDestroyNotify)vfs_mountable_free);
mountables = NULL;
read_mountable_config ();
diff --git a/metadata/metabuilder.c b/metadata/metabuilder.c
index e27d1d3..58bb57b 100644
--- a/metadata/metabuilder.c
+++ b/metadata/metabuilder.c
@@ -118,10 +118,7 @@ metadata_free (MetaData *data)
{
g_free (data->key);
if (data->is_list)
- {
- g_list_foreach (data->values, (GFunc)g_free, NULL);
- g_list_free (data->values);
- }
+ g_list_free_full (data->values, g_free);
else
g_free (data->value);
@@ -132,10 +129,8 @@ void
metafile_free (MetaFile *file)
{
g_free (file->name);
- g_list_foreach (file->children, (GFunc)metafile_free, NULL);
- g_list_free (file->children);
- g_list_foreach (file->data, (GFunc)metadata_free, NULL);
- g_list_free (file->data);
+ g_list_free_full (file->children, (GDestroyNotify)metafile_free);
+ g_list_free_full (file->data, (GDestroyNotify)metadata_free);
g_free (file);
}
@@ -226,8 +221,7 @@ meta_builder_remove (MetaBuilder *builder,
else
{
/* Removing root not allowed, just remove children */
- g_list_foreach (f->children, (GFunc)metafile_free, NULL);
- g_list_free (f->children);
+ g_list_free_full (f->children, (GDestroyNotify)metafile_free);
f->children = NULL;
if (mtime)
f->last_changed = mtime;
@@ -312,8 +306,7 @@ metadata_clear (MetaData *data)
{
if (data->is_list)
{
- g_list_foreach (data->values, (GFunc)g_free, NULL);
- g_list_free (data->values);
+ g_list_free_full (data->values, g_free);
data->values = NULL;
}
else
@@ -361,8 +354,7 @@ metafile_key_list_set (MetaFile *metafile,
metadata_clear (data);
data->is_list = TRUE;
}
- g_list_foreach (data->values, (GFunc)g_free, NULL);
- g_list_free (data->values);
+ g_list_free_full (data->values, g_free);
data->values = NULL;
}
diff --git a/monitor/afc/afcvolumemonitor.c b/monitor/afc/afcvolumemonitor.c
index 9f24753..5c39e85 100644
--- a/monitor/afc/afcvolumemonitor.c
+++ b/monitor/afc/afcvolumemonitor.c
@@ -120,13 +120,6 @@ g_vfs_afc_volume_monitor_constructor (GType type, guint ncps,
}
static void
-list_free (GList *objects)
-{
- g_list_foreach (objects, (GFunc)g_object_unref, NULL);
- g_list_free (objects);
-}
-
-static void
g_vfs_afc_volume_monitor_finalize (GObject *_self)
{
GVfsAfcVolumeMonitor *self;
@@ -134,7 +127,7 @@ g_vfs_afc_volume_monitor_finalize (GObject *_self)
self = G_VFS_AFC_VOLUME_MONITOR(_self);
if (self->volumes)
- list_free (self->volumes);
+ g_list_free_full (self->volumes, g_object_unref);
idevice_event_unsubscribe();
diff --git a/monitor/gphoto2/ggphoto2volumemonitor.c b/monitor/gphoto2/ggphoto2volumemonitor.c
index 24811d4..f299737 100644
--- a/monitor/gphoto2/ggphoto2volumemonitor.c
+++ b/monitor/gphoto2/ggphoto2volumemonitor.c
@@ -86,13 +86,6 @@ static GList* get_stores_for_camera (const char *bus_num, const char *device_num
G_DEFINE_TYPE (GGPhoto2VolumeMonitor, g_gphoto2_volume_monitor, G_TYPE_VOLUME_MONITOR)
-static void
-list_free (GList *objects)
-{
- g_list_foreach (objects, (GFunc)g_object_unref, NULL);
- g_list_free (objects);
-}
-
#ifndef HAVE_GUDEV
static HalPool *
get_hal_pool (void)
@@ -133,8 +126,8 @@ g_gphoto2_volume_monitor_finalize (GObject *object)
g_object_unref (monitor->pool);
#endif
- list_free (monitor->last_camera_devices);
- list_free (monitor->camera_volumes);
+ g_list_free_full (monitor->last_camera_devices, g_object_unref);
+ g_list_free_full (monitor->camera_volumes, g_object_unref);
if (G_OBJECT_CLASS (g_gphoto2_volume_monitor_parent_class)->finalize)
(*G_OBJECT_CLASS (g_gphoto2_volume_monitor_parent_class)->finalize) (object);
@@ -265,8 +258,7 @@ gudev_add_camera (GGPhoto2VolumeMonitor *monitor, GUdevDevice *device, gboolean
g_object_unref (activation_mount_root);
}
- g_list_foreach (store_heads, (GFunc) g_free, NULL);
- g_list_free (store_heads);
+ g_list_free_full (store_heads, g_free);
}
static void
@@ -565,8 +557,8 @@ emit_lists_in_idle (gpointer data)
"volume_added", NULL,
lists->added_volumes);
- list_free (lists->removed_volumes);
- list_free (lists->added_volumes);
+ g_list_free_full (lists->removed_volumes, g_object_unref);
+ g_list_free_full (lists->added_volumes, g_object_unref);
g_object_unref (lists->monitor);
g_free (lists);
@@ -599,8 +591,8 @@ update_all (GGPhoto2VolumeMonitor *monitor,
}
else
{
- list_free (removed_volumes);
- list_free (added_volumes);
+ g_list_free_full (removed_volumes, g_object_unref);
+ g_list_free_full (added_volumes, g_object_unref);
}
}
#endif
@@ -838,13 +830,12 @@ update_cameras (GGPhoto2VolumeMonitor *monitor,
if (activation_mount_root != NULL)
g_object_unref (activation_mount_root);
}
- g_list_foreach (store_heads, (GFunc) g_free, NULL);
- g_list_free (store_heads);
+ g_list_free_full (store_heads, g_free);
}
g_list_free (added);
g_list_free (removed);
- list_free (monitor->last_camera_devices);
+ g_list_free_full (monitor->last_camera_devices, g_object_unref);
monitor->last_camera_devices = new_camera_devices;
}
#endif
diff --git a/monitor/proxy/gproxyvolume.c b/monitor/proxy/gproxyvolume.c
index 4553ad9..a3d41a1 100644
--- a/monitor/proxy/gproxyvolume.c
+++ b/monitor/proxy/gproxyvolume.c
@@ -269,8 +269,7 @@ update_shadow_mount (GProxyVolume *volume)
break;
}
}
- g_list_foreach (mounts, (GFunc) g_object_unref, NULL);
- g_list_free (mounts);
+ g_list_free_full (mounts, g_object_unref);
if (mount_to_shadow != NULL)
{
diff --git a/monitor/proxy/gvfsproxyvolumemonitordaemon.c b/monitor/proxy/gvfsproxyvolumemonitordaemon.c
index 95eea49..8e65d9f 100644
--- a/monitor/proxy/gvfsproxyvolumemonitordaemon.c
+++ b/monitor/proxy/gvfsproxyvolumemonitordaemon.c
@@ -652,8 +652,7 @@ drive_to_dbus (GDrive *drive)
g_variant_builder_unref (expansion_builder);
g_strfreev (identifiers);
- g_list_foreach (volumes, (GFunc) g_object_unref, NULL);
- g_list_free (volumes);
+ g_list_free_full (volumes, g_object_unref);
g_free (icon_data);
g_object_unref (icon);
g_free (symbolic_icon_data);
@@ -942,12 +941,9 @@ handle_list (GVfsRemoteVolumeMonitor *object,
for (l = mounts; l; l = l->next)
g_variant_builder_add_value (mounts_array, mount_to_dbus (l->data));
- g_list_foreach (drives, (GFunc) g_object_unref, NULL);
- g_list_free (drives);
- g_list_foreach (volumes, (GFunc) g_object_unref, NULL);
- g_list_free (volumes);
- g_list_foreach (mounts, (GFunc) g_object_unref, NULL);
- g_list_free (mounts);
+ g_list_free_full (drives, g_object_unref);
+ g_list_free_full (volumes, g_object_unref);
+ g_list_free_full (mounts, g_object_unref);
gvfs_remote_volume_monitor_complete_list (object, invocation,
g_variant_builder_end (drives_array),
@@ -1067,10 +1063,7 @@ handle_mount_unmount (GVfsRemoteVolumeMonitor *object,
out:
if (mounts != NULL)
- {
- g_list_foreach (mounts, (GFunc) g_object_unref, NULL);
- g_list_free (mounts);
- }
+ g_list_free_full (mounts, g_object_unref);
return TRUE;
}
@@ -1248,10 +1241,7 @@ handle_volume_mount (GVfsRemoteVolumeMonitor *object,
out:
if (volumes != NULL)
- {
- g_list_foreach (volumes, (GFunc) g_object_unref, NULL);
- g_list_free (volumes);
- }
+ g_list_free_full (volumes, g_object_unref);
return TRUE;
}
@@ -1358,10 +1348,7 @@ handle_drive_eject (GVfsRemoteVolumeMonitor *object,
out:
if (drives != NULL)
- {
- g_list_foreach (drives, (GFunc) g_object_unref, NULL);
- g_list_free (drives);
- }
+ g_list_free_full (drives, g_object_unref);
return TRUE;
}
@@ -1468,10 +1455,7 @@ handle_drive_stop (GVfsRemoteVolumeMonitor *object,
out:
if (drives != NULL)
- {
- g_list_foreach (drives, (GFunc) g_object_unref, NULL);
- g_list_free (drives);
- }
+ g_list_free_full (drives, g_object_unref);
return TRUE;
}
@@ -1578,10 +1562,7 @@ handle_drive_start (GVfsRemoteVolumeMonitor *object,
out:
if (drives != NULL)
- {
- g_list_foreach (drives, (GFunc) g_object_unref, NULL);
- g_list_free (drives);
- }
+ g_list_free_full (drives, g_object_unref);
return TRUE;
}
@@ -1675,10 +1656,7 @@ handle_drive_poll_for_media (GVfsRemoteVolumeMonitor *object,
out:
if (drives != NULL)
- {
- g_list_foreach (drives, (GFunc) g_object_unref, NULL);
- g_list_free (drives);
- }
+ g_list_free_full (drives, g_object_unref);
return TRUE;
}
@@ -1910,8 +1888,7 @@ monitor_try_create (void)
mounts = g_volume_monitor_get_mounts (monitor);
for (l = mounts; l != NULL; l = l->next)
mount_sniff_x_content_type (G_MOUNT (l->data));
- g_list_foreach (mounts, (GFunc) g_object_unref, NULL);
- g_list_free (mounts);
+ g_list_free_full (mounts, g_object_unref);
fail:
if (klass != NULL)
diff --git a/monitor/udisks2/gvfsudisks2volumemonitor.c b/monitor/udisks2/gvfsudisks2volumemonitor.c
index 3814f4f..2163992 100644
--- a/monitor/udisks2/gvfsudisks2volumemonitor.c
+++ b/monitor/udisks2/gvfsudisks2volumemonitor.c
@@ -67,7 +67,6 @@ struct _GVfsUDisks2VolumeMonitor
GList *disc_mounts;
};
-static void object_list_free (GList *objects);
static UDisksClient *get_udisks_client_sync (GError **error);
static void update_all (GVfsUDisks2VolumeMonitor *monitor,
@@ -133,13 +132,13 @@ gvfs_udisks2_volume_monitor_finalize (GObject *object)
g_clear_object (&monitor->client);
g_clear_object (&monitor->gudev_client);
- object_list_free (monitor->drives);
- object_list_free (monitor->volumes);
- object_list_free (monitor->fstab_volumes);
- object_list_free (monitor->mounts);
+ g_list_free_full (monitor->drives, g_object_unref);
+ g_list_free_full (monitor->volumes, g_object_unref);
+ g_list_free_full (monitor->fstab_volumes, g_object_unref);
+ g_list_free_full (monitor->mounts, g_object_unref);
- object_list_free (monitor->disc_volumes);
- object_list_free (monitor->disc_mounts);
+ g_list_free_full (monitor->disc_volumes, g_object_unref);
+ g_list_free_full (monitor->disc_mounts, g_object_unref);
G_OBJECT_CLASS (gvfs_udisks2_volume_monitor_parent_class)->finalize (object);
}
@@ -472,15 +471,6 @@ diff_sorted_lists (GList *list1,
/* ---------------------------------------------------------------------------------------------------- */
static void
-object_list_free (GList *objects)
-{
- g_list_foreach (objects, (GFunc)g_object_unref, NULL);
- g_list_free (objects);
-}
-
-/* ---------------------------------------------------------------------------------------------------- */
-
-static void
object_list_emit (GVfsUDisks2VolumeMonitor *monitor,
const gchar *monitor_signal,
const gchar *object_signal,
@@ -572,12 +562,12 @@ update_all (GVfsUDisks2VolumeMonitor *monitor,
added_mounts);
}
- object_list_free (removed_drives);
- object_list_free (added_drives);
- object_list_free (removed_volumes);
- object_list_free (added_volumes);
- object_list_free (removed_mounts);
- object_list_free (added_mounts);
+ g_list_free_full (removed_drives, g_object_unref);
+ g_list_free_full (added_drives, g_object_unref);
+ g_list_free_full (removed_volumes, g_object_unref);
+ g_list_free_full (added_volumes, g_object_unref);
+ g_list_free_full (removed_mounts, g_object_unref);
+ g_list_free_full (added_mounts, g_object_unref);
}
/* ---------------------------------------------------------------------------------------------------- */
@@ -1249,8 +1239,7 @@ find_volume_for_device (GVfsUDisks2VolumeMonitor *monitor,
}
out:
- g_list_foreach (blocks, (GFunc) g_object_unref, NULL);
- g_list_free (blocks);
+ g_list_free_full (blocks, g_object_unref);
return ret;
}
@@ -1357,8 +1346,7 @@ update_drives (GVfsUDisks2VolumeMonitor *monitor,
g_list_free (cur_udisks_drives);
g_list_free (new_udisks_drives);
- g_list_foreach (objects, (GFunc) g_object_unref, NULL);
- g_list_free (objects);
+ g_list_free_full (objects, g_object_unref);
}
/* ---------------------------------------------------------------------------------------------------- */
@@ -1448,8 +1436,7 @@ update_volumes (GVfsUDisks2VolumeMonitor *monitor,
g_list_free (new_block_volumes);
g_list_free (cur_block_volumes);
- g_list_foreach (objects, (GFunc) g_object_unref, NULL);
- g_list_free (objects);
+ g_list_free_full (objects, g_object_unref);
}
/* ---------------------------------------------------------------------------------------------------- */
@@ -1535,8 +1522,7 @@ mount_point_has_device (GVfsUDisks2VolumeMonitor *monitor,
ret = TRUE;
out:
- g_list_foreach (blocks, (GFunc) g_object_unref, NULL);
- g_list_free (blocks);
+ g_list_free_full (blocks, g_object_unref);
return ret;
}
@@ -1629,8 +1615,7 @@ update_fstab_volumes (GVfsUDisks2VolumeMonitor *monitor,
}
}
- g_list_foreach (new_mount_points, (GFunc) g_unix_mount_point_free, NULL);
- g_list_free (new_mount_points);
+ g_list_free_full (new_mount_points, (GDestroyNotify) g_unix_mount_point_free);
g_list_free (cur_mount_points);
}
@@ -1744,8 +1729,7 @@ update_mounts (GVfsUDisks2VolumeMonitor *monitor,
g_list_free (removed);
g_list_free (unchanged);
- g_list_foreach (new_mounts, (GFunc) g_unix_mount_free, NULL);
- g_list_free (new_mounts);
+ g_list_free_full (new_mounts, (GDestroyNotify) g_unix_mount_free);
g_list_free (cur_mounts);
}
@@ -1895,8 +1879,7 @@ update_discs (GVfsUDisks2VolumeMonitor *monitor,
g_list_free (new_disc_drives);
g_list_free (cur_disc_drives);
- g_list_foreach (objects, (GFunc) g_object_unref, NULL);
- g_list_free (objects);
+ g_list_free_full (objects, g_object_unref);
}
/* ---------------------------------------------------------------------------------------------------- */
diff --git a/programs/gvfs-mount.c b/programs/gvfs-mount.c
index 68e9267..a9b1b58 100644
--- a/programs/gvfs-mount.c
+++ b/programs/gvfs-mount.c
@@ -704,8 +704,7 @@ list_drives (GList *drives,
}
volumes = g_drive_get_volumes (drive);
list_volumes (volumes, indent + 2, FALSE);
- g_list_foreach (volumes, (GFunc)g_object_unref, NULL);
- g_list_free (volumes);
+ g_list_free_full (volumes, g_object_unref);
}
}
@@ -723,18 +722,15 @@ list_monitor_items(void)
drives = g_volume_monitor_get_connected_drives (volume_monitor);
list_drives (drives, 0);
- g_list_foreach (drives, (GFunc)g_object_unref, NULL);
- g_list_free (drives);
+ g_list_free_full (drives, g_object_unref);
volumes = g_volume_monitor_get_volumes (volume_monitor);
list_volumes (volumes, 0, TRUE);
- g_list_foreach (volumes, (GFunc)g_object_unref, NULL);
- g_list_free (volumes);
+ g_list_free_full (volumes, g_object_unref);
mounts = g_volume_monitor_get_mounts (volume_monitor);
list_mounts (mounts, 0, TRUE);
- g_list_foreach (mounts, (GFunc)g_object_unref, NULL);
- g_list_free (mounts);
+ g_list_free_full (mounts, g_object_unref);
g_object_unref (volume_monitor);
}
@@ -762,8 +758,7 @@ unmount_all_with_scheme (const char *scheme)
}
g_object_unref (root);
}
- g_list_foreach (mounts, (GFunc)g_object_unref, NULL);
- g_list_free (mounts);
+ g_list_free_full (mounts, g_object_unref);
g_object_unref (volume_monitor);
}
@@ -844,8 +839,7 @@ mount_with_device_file (const char *device_file)
outstanding_mounts++;
}
}
- g_list_foreach (volumes, (GFunc) g_object_unref, NULL);
- g_list_free (volumes);
+ g_list_free_full (volumes, g_object_unref);
if (outstanding_mounts == 0)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]