Branch: refs/heads/master Author: Colomban Wendling ban@herbesfolles.org Committer: Colomban Wendling ban@herbesfolles.org Date: Thu, 16 Nov 2023 09:56:02 UTC Commit: 727e8cde61d5357a63538df96ab4ca6c4cc8f931 https://github.com/geany/geany/commit/727e8cde61d5357a63538df96ab4ca6c4cc8f9...
Log Message: ----------- Use g_*list_free_full() instead of g_*list_foreach()
Simplifies code and avoids unnecessary or shady casts passing the element free function.
Modified Paths: -------------- plugins/filebrowser.c src/dialogs.c src/filetypes.c src/plugins.c src/toolbar.c
Modified: plugins/filebrowser.c 12 lines changed, 4 insertions(+), 8 deletions(-) =================================================================== @@ -526,8 +526,7 @@ static void on_external_open(GtkMenuItem *menuitem, gpointer user_data) } }
- g_list_foreach(list, (GFunc) gtk_tree_path_free, NULL); - g_list_free(list); + g_list_free_full(list, (GDestroyNotify) gtk_tree_path_free); }
@@ -551,8 +550,7 @@ static void open_selected_files(GList *list, gboolean do_not_focus) if (doc != NULL && ! do_not_focus) keybindings_send_command(GEANY_KEY_GROUP_FOCUS, GEANY_KEYS_FOCUS_EDITOR);
- g_slist_foreach(files, (GFunc) g_free, NULL); /* free filenames */ - g_slist_free(files); + g_slist_free_full(files, g_free); }
@@ -589,8 +587,7 @@ static void on_open_clicked(GtkMenuItem *menuitem, gpointer user_data) else open_selected_files(list, GPOINTER_TO_INT(user_data));
- g_list_foreach(list, (GFunc) gtk_tree_path_free, NULL); - g_list_free(list); + g_list_free_full(list, (GDestroyNotify) gtk_tree_path_free); }
@@ -620,8 +617,7 @@ static void on_find_in_files(GtkMenuItem *menuitem, gpointer user_data) else dir = g_strdup(current_dir);
- g_list_foreach(list, (GFunc) gtk_tree_path_free, NULL); - g_list_free(list); + g_list_free_full(list, (GDestroyNotify) gtk_tree_path_free);
SETPTR(dir, utils_get_utf8_from_locale(dir)); search_show_find_in_files_dialog(dir);
Modified: src/dialogs.c 3 lines changed, 1 insertions(+), 2 deletions(-) =================================================================== @@ -163,9 +163,8 @@ static gboolean open_file_dialog_handle_response(GtkWidget *dialog, gint respons { document_open_files(filelist, ro, ft, charset); } - g_slist_foreach(filelist, (GFunc) g_free, NULL); /* free filenames */ + g_slist_free_full(filelist, g_free); } - g_slist_free(filelist); } if (app->project && !EMPTY(app->project->base_path)) gtk_file_chooser_remove_shortcut_folder(GTK_FILE_CHOOSER(dialog),
Modified: src/filetypes.c 3 lines changed, 1 insertions(+), 2 deletions(-) =================================================================== @@ -844,8 +844,7 @@ static void filetype_free(gpointer data, G_GNUC_UNUSED gpointer user_data)
if (ft->priv->error_regex) g_regex_unref(ft->priv->error_regex); - g_slist_foreach(ft->priv->tag_files, (GFunc) g_free, NULL); - g_slist_free(ft->priv->tag_files); + g_slist_free_full(ft->priv->tag_files, g_free);
g_free(ft->priv); g_free(ft);
Modified: src/plugins.c 6 lines changed, 2 insertions(+), 4 deletions(-) =================================================================== @@ -1108,8 +1108,7 @@ load_plugins_from_path(const gchar *path) g_free(fname); }
- g_slist_foreach(list, (GFunc) g_free, NULL); - g_slist_free(list); + g_slist_free_full(list, g_free);
if (count) geany_debug("Added %d plugin(s) in '%s'.", count, path); @@ -1311,8 +1310,7 @@ void plugins_finalize(void) { if (failed_plugins_list != NULL) { - g_list_foreach(failed_plugins_list, (GFunc) g_free, NULL); - g_list_free(failed_plugins_list); + g_list_free_full(failed_plugins_list, g_free); } /* Have to loop because proxys cannot be unloaded until after all their * plugins are unloaded as well (the second loop should should catch all the remaining ones) */
Modified: src/toolbar.c 3 lines changed, 1 insertions(+), 2 deletions(-) =================================================================== @@ -1118,8 +1118,7 @@ void toolbar_configure(GtkWindow *parent)
gtk_widget_destroy(tbw->dialog);
- g_slist_foreach(used_items, (GFunc) g_free, NULL); - g_slist_free(used_items); + g_slist_free_full(used_items, g_free); g_list_free(all_items); tb_editor_free_path(tbw); g_free(tbw);
-------------- This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).