diff options
author | rbuj <[email protected]> | 2019-09-12 11:21:56 +0200 |
---|---|---|
committer | raveit65 <[email protected]> | 2019-09-22 02:44:09 +0200 |
commit | e5d2b428b86f3a09bbd035332698123971545d99 (patch) | |
tree | e22397390228d4b0099adf8ab64bd6bee67e4999 /src | |
parent | 68ef9e00239ad3f20f78fb4822446dce62d58bab (diff) | |
download | engrampa-e5d2b428b86f3a09bbd035332698123971545d99.tar.bz2 engrampa-e5d2b428b86f3a09bbd035332698123971545d99.tar.xz |
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.
Diffstat (limited to 'src')
-rw-r--r-- | src/dlg-add-files.c | 3 | ||||
-rw-r--r-- | src/eggfileformatchooser.c | 3 | ||||
-rw-r--r-- | src/file-utils.c | 3 | ||||
-rw-r--r-- | src/fr-process.c | 6 | ||||
-rw-r--r-- | src/fr-window.c | 3 | ||||
-rw-r--r-- | src/gio-utils.c | 3 | ||||
-rw-r--r-- | src/java-utils.c | 12 |
7 files changed, 11 insertions, 22 deletions
diff --git a/src/dlg-add-files.c b/src/dlg-add-files.c index fed6ed8..add0a71 100644 --- a/src/dlg-add-files.c +++ b/src/dlg-add-files.c @@ -123,8 +123,7 @@ file_sel_response_cb (GtkWidget *widget, fr_window_archive_add_files (window, item_list, update); gio_file_list_free (item_list); - g_slist_foreach (selections, (GFunc) g_free, NULL); - g_slist_free (selections); + g_slist_free_full (selections, g_free); g_free (current_folder); gtk_widget_destroy (data->dialog); diff --git a/src/eggfileformatchooser.c b/src/eggfileformatchooser.c index cd9d4a0..f4d5a4e 100644 --- a/src/eggfileformatchooser.c +++ b/src/eggfileformatchooser.c @@ -106,8 +106,7 @@ egg_file_format_filter_info_free (gpointer boxed) self = boxed; g_hash_table_unref (self->extension_set); - g_slist_foreach (self->extension_list, (GFunc) g_free, NULL); - g_slist_free (self->extension_list); + g_slist_free_full (self->extension_list, g_free); g_free (self->name); g_free (self); } diff --git a/src/file-utils.c b/src/file-utils.c index b0949da..c8b1823 100644 --- a/src/file-utils.c +++ b/src/file-utils.c @@ -755,8 +755,7 @@ path_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/fr-process.c b/src/fr-process.c index a5621a9..d82bacd 100644 --- a/src/fr-process.c +++ b/src/fr-process.c @@ -93,8 +93,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; } @@ -173,8 +172,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 7268b89..99dc120 100644 --- a/src/fr-window.c +++ b/src/fr-window.c @@ -220,8 +220,7 @@ fr_clipboard_data_unref (FrClipboardData *clipboard_data) g_free (clipboard_data->base_dir); g_free (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 2ea4a3c..b1acd3d 100644 --- a/src/gio-utils.c +++ b/src/gio-utils.c @@ -1129,8 +1129,7 @@ directory_copy_data_free (DirectoryCopyData *dcd) g_object_unref (dcd->current_destination); dcd->current_destination = NULL; } - g_list_foreach (dcd->to_copy, (GFunc) child_data_free, NULL); - g_list_free (dcd->to_copy); + g_list_free_full (dcd->to_copy, (GDestroyNotify) child_data_free); g_free (dcd); } diff --git a/src/java-utils.c b/src/java-utils.c index ce77c8d..1aed8a5 100644 --- a/src/java-utils.c +++ b/src/java-utils.c @@ -125,20 +125,16 @@ 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); - } + if (cfile->const_pool_class != NULL) + g_slist_free_full (cfile->const_pool_class, g_free); for (scan = cfile->const_pool_utf; scan ; scan = scan->next) { struct utf_string *string = scan->data; g_free (string->str); } - if (cfile->const_pool_utf != NULL) { - g_slist_foreach (cfile->const_pool_utf, (GFunc)g_free, NULL); - g_slist_free (cfile->const_pool_utf); - } + if (cfile->const_pool_utf != NULL) + g_slist_free_full (cfile->const_pool_utf, g_free); if (cfile->fd != -1) close (cfile->fd); |