diff options
author | Tomas Bzatek <tbzatek@redhat.com> | 2013-01-17 11:57:43 +0100 |
---|---|---|
committer | Tomas Bzatek <tbzatek@redhat.com> | 2013-01-17 11:57:43 +0100 |
commit | fd135fe90ce9b9a568468c4ddb21e6d13135e80d (patch) | |
tree | 77a3a34834640f00797fb8b5e072b7356706231e /monitor | |
parent | 85e2ef5741bc0e165e6e74a70917bd7f0390444f (diff) | |
download | gvfs-fd135fe90ce9b9a568468c4ddb21e6d13135e80d.tar.gz |
Use g_list_free_full() where applicable
Diffstat (limited to 'monitor')
-rw-r--r-- | monitor/afc/afcvolumemonitor.c | 9 | ||||
-rw-r--r-- | monitor/gphoto2/ggphoto2volumemonitor.c | 27 | ||||
-rw-r--r-- | monitor/proxy/gproxyvolume.c | 3 | ||||
-rw-r--r-- | monitor/proxy/gvfsproxyvolumemonitordaemon.c | 45 | ||||
-rw-r--r-- | monitor/udisks2/gvfsudisks2volumemonitor.c | 55 |
5 files changed, 41 insertions, 98 deletions
diff --git a/monitor/afc/afcvolumemonitor.c b/monitor/afc/afcvolumemonitor.c index 9f24753a..5c39e852 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 24811d45..f2997372 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 4553ad99..a3d41a18 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 95eea496..8e65d9fc 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 3814f4fd..2163992b 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); } /* ---------------------------------------------------------------------------------------------------- */ |