diff options
author | rbuj <[email protected]> | 2019-03-14 08:19:47 +0100 |
---|---|---|
committer | raveit65 <[email protected]> | 2019-04-22 19:27:03 +0200 |
commit | fc7d34b3b9a99a9d2c8932d386cb54c810adb681 (patch) | |
tree | 3816512afb33fc69236839f9d1420c930493b098 | |
parent | 4b08d3116c7fc759feff92d627d45397db2446ea (diff) | |
download | mate-applets-fc7d34b3b9a99a9d2c8932d386cb54c810adb681.tar.bz2 mate-applets-fc7d34b3b9a99a9d2c8932d386cb54c810adb681.tar.xz |
Use g_list_free_full() convenience function
void
g_list_free_full (GList *list,
GDestroyNotify free_func);
Convenience method, which frees all the memory used
by a GList, and calls free_func on every element's
data.
https://developer.gnome.org/glib/stable/glib-Doubly-Linked-Lists.html#g-list-free-full
-rw-r--r-- | cpufreq/src/cpufreq-monitor.c | 10 | ||||
-rw-r--r-- | cpufreq/src/cpufreq-selector/cpufreq-selector-sysfs.c | 12 | ||||
-rw-r--r-- | netspeed/src/backend.c | 3 | ||||
-rw-r--r-- | trashapplet/src/trashapplet.c | 6 |
4 files changed, 8 insertions, 23 deletions
diff --git a/cpufreq/src/cpufreq-monitor.c b/cpufreq/src/cpufreq-monitor.c index caf962fa..38ffa0e2 100644 --- a/cpufreq/src/cpufreq-monitor.c +++ b/cpufreq/src/cpufreq-monitor.c @@ -175,18 +175,12 @@ cpufreq_monitor_finalize (GObject *object) } if (monitor->priv->available_freqs) { - g_list_foreach (monitor->priv->available_freqs, - (GFunc) g_free, - NULL); - g_list_free (monitor->priv->available_freqs); + g_list_free_full (monitor->priv->available_freqs, g_free); monitor->priv->available_freqs = NULL; } if (monitor->priv->available_govs) { - g_list_foreach (monitor->priv->available_govs, - (GFunc) g_free, - NULL); - g_list_free (monitor->priv->available_govs); + g_list_free_full (monitor->priv->available_govs, g_free); monitor->priv->available_govs = NULL; } diff --git a/cpufreq/src/cpufreq-selector/cpufreq-selector-sysfs.c b/cpufreq/src/cpufreq-selector/cpufreq-selector-sysfs.c index 30e05532..990ea702 100644 --- a/cpufreq/src/cpufreq-selector/cpufreq-selector-sysfs.c +++ b/cpufreq/src/cpufreq-selector/cpufreq-selector-sysfs.c @@ -78,18 +78,12 @@ cpufreq_selector_sysfs_finalize (GObject *object) CPUFreqSelectorSysfs *selector = CPUFREQ_SELECTOR_SYSFS (object); if (selector->priv->available_freqs) { - g_list_foreach (selector->priv->available_freqs, - (GFunc) g_free, - NULL); - g_list_free (selector->priv->available_freqs); + g_list_free_full (selector->priv->available_freqs, g_free); selector->priv->available_freqs = NULL; } - + if (selector->priv->available_govs) { - g_list_foreach (selector->priv->available_govs, - (GFunc) g_free, - NULL); - g_list_free (selector->priv->available_govs); + g_list_free_full (selector->priv->available_govs, g_free); selector->priv->available_govs = NULL; } diff --git a/netspeed/src/backend.c b/netspeed/src/backend.c index bc5c91f0..a3418f82 100644 --- a/netspeed/src/backend.c +++ b/netspeed/src/backend.c @@ -122,8 +122,7 @@ get_default_route(void) void free_devices_list(GList *list) { - g_list_foreach(list, (GFunc)g_free, NULL); - g_list_free(list); + g_list_free_full (list, g_free); } diff --git a/trashapplet/src/trashapplet.c b/trashapplet/src/trashapplet.c index 4d99f576..b2fc95f0 100644 --- a/trashapplet/src/trashapplet.c +++ b/trashapplet/src/trashapplet.c @@ -588,10 +588,8 @@ trash_applet_drag_data_received (GtkWidget *widget, } } - g_list_foreach (untrashable, (GFunc)g_object_unref, NULL); - g_list_free (untrashable); - g_list_foreach (trashed, (GFunc)g_object_unref, NULL); - g_list_free (trashed); + g_list_free_full (untrashable, g_object_unref); + g_list_free_full (trashed, g_object_unref); g_strfreev (list); |