[file-roller/wip/jtojnar/engrampa-backports: 14/24] Use g_list_free_full and g_slist_free_full
- From: Jan Tojnar <jtojnar src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [file-roller/wip/jtojnar/engrampa-backports: 14/24] Use g_list_free_full and g_slist_free_full
- Date: Wed, 27 Jul 2022 19:54:32 +0000 (UTC)
commit fed413280069634e0efe591c7bf145cdaf4bec78
Author: rbuj <robert buj gmail com>
Date: Thu Sep 12 11:21:56 2019 +0200
Use g_list_free_full and g_slist_free_full
void g_list_free_full (GList *list, GDestroyNotify free_func);
void g_slist_free_full (GList *list, GDestroyNotify free_func);
Convenience methods, which free all the memory used by a list,
and calls free_func on every element's data.
Based on https://github.com/mate-desktop/engrampa/commit/e5d2b428b86f3a09bbd035332698123971545d99
Co-Authored-By: Jan Tojnar <jtojnar gmail com>
src/eggtreemultidnd.c | 3 +--
src/fr-process.c | 6 ++----
src/fr-window.c | 3 +--
src/gio-utils.c | 9 +++------
src/glib-utils.c | 6 ++----
src/java-utils.c | 6 ++----
6 files changed, 11 insertions(+), 22 deletions(-)
---
diff --git a/src/eggtreemultidnd.c b/src/eggtreemultidnd.c
index 6bcecd6c..e77d79c9 100644
--- a/src/eggtreemultidnd.c
+++ b/src/eggtreemultidnd.c
@@ -205,8 +205,7 @@ selection_foreach (GtkTreeModel *model,
static void
path_list_free (GList *path_list)
{
- g_list_foreach (path_list, (GFunc) gtk_tree_row_reference_free, NULL);
- g_list_free (path_list);
+ g_list_free_full (path_list, (GDestroyNotify) gtk_tree_row_reference_free);
}
diff --git a/src/fr-process.c b/src/fr-process.c
index e36f552a..a3ddc9f2 100644
--- a/src/fr-process.c
+++ b/src/fr-process.c
@@ -81,8 +81,7 @@ fr_command_info_free (FrCommandInfo *info)
return;
if (info->args != NULL) {
- g_list_foreach (info->args, (GFunc) g_free, NULL);
- g_list_free (info->args);
+ g_list_free_full (info->args, g_free);
info->args = NULL;
}
@@ -164,8 +163,7 @@ fr_channel_data_reset (FrChannelData *channel)
fr_channel_data_close_source (channel);
if (channel->raw != NULL) {
- g_list_foreach (channel->raw, (GFunc) g_free, NULL);
- g_list_free (channel->raw);
+ g_list_free_full (channel->raw, g_free);
channel->raw = NULL;
}
}
diff --git a/src/fr-window.c b/src/fr-window.c
index 51bcec23..b202d185 100644
--- a/src/fr-window.c
+++ b/src/fr-window.c
@@ -193,8 +193,7 @@ fr_clipboard_data_unref (FrClipboardData *clipboard_data)
g_free (clipboard_data->base_dir);
_g_object_unref (clipboard_data->tmp_dir);
g_free (clipboard_data->current_dir);
- g_list_foreach (clipboard_data->files, (GFunc) g_free, NULL);
- g_list_free (clipboard_data->files);
+ g_list_free_full (clipboard_data->files, g_free);
g_free (clipboard_data);
}
diff --git a/src/gio-utils.c b/src/gio-utils.c
index 858c1215..bfb1a360 100644
--- a/src/gio-utils.c
+++ b/src/gio-utils.c
@@ -61,8 +61,7 @@ file_info_free (FileInfo *file_info)
void
file_info_list_free (GList *list)
{
- g_list_foreach (list, (GFunc) file_info_free, NULL);
- g_list_free (list);
+ g_list_free_full (list, (GDestroyNotify) file_info_free);
}
@@ -185,8 +184,7 @@ for_each_child_data_free (ForEachChildData *fec)
_g_info_data_freev (&(fec->current));
g_free (fec->attributes);
if (fec->to_visit != NULL) {
- g_list_foreach (fec->to_visit, (GFunc) file_info_free, NULL);
- g_list_free (fec->to_visit);
+ g_list_free_full (fec->to_visit, (GDestroyNotify) file_info_free);
}
_g_object_unref (fec->cancellable);
g_free (fec);
@@ -947,8 +945,7 @@ directory_copy_data_free (DirectoryCopyData *dcd)
g_object_unref (dcd->current_destination);
dcd->current_destination = NULL;
}
- g_list_foreach (dcd->to_copy, (GFunc) file_info_free, NULL);
- g_list_free (dcd->to_copy);
+ g_list_free_full (dcd->to_copy, (GDestroyNotify) file_info_free);
g_free (dcd);
}
diff --git a/src/glib-utils.c b/src/glib-utils.c
index 11db6e5a..c46a7da8 100644
--- a/src/glib-utils.c
+++ b/src/glib-utils.c
@@ -76,8 +76,7 @@ _g_object_list_ref (GList *list)
void
_g_object_list_unref (GList *list)
{
- g_list_foreach (list, (GFunc) g_object_unref, NULL);
- g_list_free (list);
+ g_list_free_full (list, (GDestroyNotify) g_object_unref);
}
/* enum */
@@ -462,8 +461,7 @@ _g_string_list_free (GList *path_list)
{
if (path_list == NULL)
return;
- g_list_foreach (path_list, (GFunc) g_free, NULL);
- g_list_free (path_list);
+ g_list_free_full (path_list, g_free);
}
diff --git a/src/java-utils.c b/src/java-utils.c
index c091f0b7..3bd132e9 100644
--- a/src/java-utils.c
+++ b/src/java-utils.c
@@ -125,8 +125,7 @@ java_class_file_free (JavaClassFile *cfile)
GSList *scan;
if (cfile->const_pool_class != NULL) {
- g_slist_foreach (cfile->const_pool_class, (GFunc)g_free, NULL);
- g_slist_free (cfile->const_pool_class);
+ g_slist_free_full (cfile->const_pool_class, g_free);
}
for (scan = cfile->const_pool_utf; scan ; scan = scan->next) {
@@ -135,8 +134,7 @@ java_class_file_free (JavaClassFile *cfile)
}
if (cfile->const_pool_utf != NULL) {
- g_slist_foreach (cfile->const_pool_utf, (GFunc)g_free, NULL);
- g_slist_free (cfile->const_pool_utf);
+ g_slist_free_full (cfile->const_pool_utf, g_free);
}
if (cfile->fd != -1)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]