Commit fcfb7cf1 authored by Michael Natterer's avatar Michael Natterer 😴

Use the new g_[s]list_free_full() instead of foreach() and free()

parent 514a5548
......@@ -266,8 +266,7 @@ gimp_data_finalize (GObject *object)
if (private->tags)
{
g_list_foreach (private->tags, (GFunc) g_object_unref, NULL);
g_list_free (private->tags);
g_list_free_full (private->tags, (GDestroyNotify) g_object_unref);
private->tags = NULL;
}
......
......@@ -966,8 +966,7 @@ gimp_image_finalize (GObject *object)
if (private->guides)
{
g_list_foreach (private->guides, (GFunc) g_object_unref, NULL);
g_list_free (private->guides);
g_list_free_full (private->guides, (GDestroyNotify) g_object_unref);
private->guides = NULL;
}
......@@ -979,9 +978,8 @@ gimp_image_finalize (GObject *object)
if (private->sample_points)
{
g_list_foreach (private->sample_points,
(GFunc) gimp_sample_point_unref, NULL);
g_list_free (private->sample_points);
g_list_free_full (private->sample_points,
(GDestroyNotify) gimp_sample_point_unref);
private->sample_points = NULL;
}
......@@ -1138,12 +1136,10 @@ gimp_image_size_changed (GimpViewable *viewable)
g_list_free (all_items);
all_items = gimp_image_get_channel_list (image);
g_list_foreach (all_items, (GFunc) gimp_viewable_size_changed, NULL);
g_list_free (all_items);
g_list_free_full (all_items, (GDestroyNotify) gimp_viewable_size_changed);
all_items = gimp_image_get_vectors_list (image);
g_list_foreach (all_items, (GFunc) gimp_viewable_size_changed, NULL);
g_list_free (all_items);
g_list_free_full (all_items, (GDestroyNotify) gimp_viewable_size_changed);
gimp_viewable_size_changed (GIMP_VIEWABLE (gimp_image_get_mask (image)));
......
......@@ -556,8 +556,7 @@ gimp_palette_import_from_file (GimpContext *context,
gimp_object_set_name (GIMP_OBJECT (palette), palette_name);
g_list_foreach (palette_list, (GFunc) g_object_unref, NULL);
g_list_free (palette_list);
g_list_free_full (palette_list, (GDestroyNotify) g_object_unref);
return palette;
}
......
......@@ -125,8 +125,8 @@ gimp_palette_finalize (GObject *object)
if (palette->colors)
{
g_list_foreach (palette->colors, (GFunc) gimp_palette_entry_free, NULL);
g_list_free (palette->colors);
g_list_free_full (palette->colors,
(GDestroyNotify) gimp_palette_entry_free);
palette->colors = NULL;
}
......
......@@ -155,9 +155,7 @@ gimp_preview_cache_invalidate (GSList **plist)
preview_cache_print (*plist);
#endif
g_slist_foreach (*plist, (GFunc) temp_buf_free, NULL);
g_slist_free (*plist);
g_slist_free_full (*plist, (GDestroyNotify) temp_buf_free);
*plist = NULL;
}
......
......@@ -157,8 +157,7 @@ gimp_tag_cache_finalize (GObject *object)
GimpTagCacheRecord *rec = &g_array_index (cache->priv->records,
GimpTagCacheRecord, i);
g_list_foreach (rec->tags, (GFunc) g_object_unref, NULL);
g_list_free (rec->tags);
g_list_free_full (rec->tags, (GDestroyNotify) g_object_unref);
}
g_array_free (cache->priv->records, TRUE);
......
......@@ -203,8 +203,7 @@ file_open_dialog_response (GtkWidget *open_dialog,
gimp_file_dialog_set_sensitive (dialog, TRUE);
}
g_slist_foreach (uris, (GFunc) g_free, NULL);
g_slist_free (uris);
g_slist_free_full (uris, (GDestroyNotify) g_free);
}
static GimpImage *
......
......@@ -122,8 +122,7 @@ gimp_canvas_group_dispose (GObject *object)
if (private->items)
{
g_list_foreach (private->items, (GFunc) g_object_unref, NULL);
g_list_free (private->items);
g_list_free_full (private->items, (GDestroyNotify) g_object_unref);
private->items = NULL;
}
......
......@@ -191,9 +191,8 @@ gimp_scale_combo_box_finalize (GObject *object)
if (combo_box->mru)
{
g_list_foreach (combo_box->mru,
(GFunc) gtk_tree_row_reference_free, NULL);
g_list_free (combo_box->mru);
g_list_free_full (combo_box->mru,
(GDestroyNotify) gtk_tree_row_reference_free);
combo_box->mru = NULL;
}
......
......@@ -282,8 +282,8 @@ gimp_statusbar_finalize (GObject *object)
statusbar->icon = NULL;
}
g_slist_foreach (statusbar->messages, (GFunc) gimp_statusbar_msg_free, NULL);
g_slist_free (statusbar->messages);
g_slist_free_full (statusbar->messages,
(GDestroyNotify) gimp_statusbar_msg_free);
statusbar->messages = NULL;
if (statusbar->context_ids)
......
......@@ -495,8 +495,7 @@ splash_image_pick_from_dir (const gchar *dirname,
if (be_verbose)
g_printerr (pixbuf ? "OK\n" : "failed\n");
g_list_foreach (splashes, (GFunc) g_free, NULL);
g_list_free (splashes);
g_list_free_full (splashes, (GDestroyNotify) g_free);
}
}
......
......@@ -464,10 +464,7 @@ gimp_pdb_entry_free (gpointer key,
gpointer user_data)
{
if (value)
{
g_list_foreach (value, (GFunc) g_object_unref, NULL);
g_list_free (value);
}
g_list_free_full (value, (GDestroyNotify) g_object_unref);
}
static gint64
......
......@@ -67,8 +67,7 @@ gimp_plug_in_def_finalize (GObject *object)
g_free (plug_in_def->help_domain_name);
g_free (plug_in_def->help_domain_uri);
g_slist_foreach (plug_in_def->procedures, (GFunc) g_object_unref, NULL);
g_slist_free (plug_in_def->procedures);
g_slist_free_full (plug_in_def->procedures, (GDestroyNotify) g_object_unref);
G_OBJECT_CLASS (parent_class)->finalize (object);
}
......
......@@ -167,8 +167,7 @@ gimp_plug_in_manager_restore (GimpPlugInManager *manager,
}
/* we're done with the plug-in-defs */
g_slist_foreach (manager->plug_in_defs, (GFunc) g_object_unref, NULL);
g_slist_free (manager->plug_in_defs);
g_slist_free_full (manager->plug_in_defs, (GDestroyNotify) g_object_unref);
manager->plug_in_defs = NULL;
/* bind plug-in text domains */
......
......@@ -194,16 +194,15 @@ gimp_plug_in_manager_finalize (GObject *object)
if (manager->plug_in_procedures)
{
g_slist_foreach (manager->plug_in_procedures,
(GFunc) g_object_unref, NULL);
g_slist_free (manager->plug_in_procedures);
g_slist_free_full (manager->plug_in_procedures,
(GDestroyNotify) g_object_unref);
manager->plug_in_procedures = NULL;
}
if (manager->plug_in_defs)
{
g_slist_foreach (manager->plug_in_defs, (GFunc) g_object_unref, NULL);
g_slist_free (manager->plug_in_defs);
g_slist_free_full (manager->plug_in_defs,
(GDestroyNotify) g_object_unref);
manager->plug_in_defs = NULL;
}
......
......@@ -125,8 +125,7 @@ gimp_plug_in_procedure_finalize (GObject *object)
g_free (proc->prog);
g_free (proc->menu_label);
g_list_foreach (proc->menu_paths, (GFunc) g_free, NULL);
g_list_free (proc->menu_paths);
g_list_free_full (proc->menu_paths, (GDestroyNotify) g_free);
g_free (proc->label);
......@@ -138,14 +137,9 @@ gimp_plug_in_procedure_finalize (GObject *object)
g_free (proc->magics);
g_free (proc->mime_type);
g_slist_foreach (proc->extensions_list, (GFunc) g_free, NULL);
g_slist_free (proc->extensions_list);
g_slist_foreach (proc->prefixes_list, (GFunc) g_free, NULL);
g_slist_free (proc->prefixes_list);
g_slist_foreach (proc->magics_list, (GFunc) g_free, NULL);
g_slist_free (proc->magics_list);
g_slist_free_full (proc->extensions_list, (GDestroyNotify) g_free);
g_slist_free_full (proc->prefixes_list, (GDestroyNotify) g_free);
g_slist_free_full (proc->magics_list, (GDestroyNotify) g_free);
g_free (proc->thumb_loader);
......@@ -882,10 +876,7 @@ gimp_plug_in_procedure_set_file_proc (GimpPlugInProcedure *proc,
}
if (proc->extensions_list)
{
g_slist_foreach (proc->extensions_list, (GFunc) g_free, NULL);
g_slist_free (proc->extensions_list);
}
g_slist_free_full (proc->extensions_list, (GDestroyNotify) g_free);
proc->extensions_list = extensions_parse (proc->extensions);
......@@ -900,10 +891,7 @@ gimp_plug_in_procedure_set_file_proc (GimpPlugInProcedure *proc,
}
if (proc->prefixes_list)
{
g_slist_foreach (proc->prefixes_list, (GFunc) g_free, NULL);
g_slist_free (proc->prefixes_list);
}
g_slist_free_full (proc->prefixes_list, (GDestroyNotify) g_free);
proc->prefixes_list = extensions_parse (proc->prefixes);
......@@ -931,10 +919,7 @@ gimp_plug_in_procedure_set_file_proc (GimpPlugInProcedure *proc,
}
if (proc->magics_list)
{
g_slist_foreach (proc->magics_list, (GFunc) g_free, NULL);
g_slist_free (proc->magics_list);
}
g_slist_free_full (proc->magics_list, (GDestroyNotify) g_free);
proc->magics_list = extensions_parse (proc->magics);
}
......
......@@ -106,8 +106,8 @@ gimp_plug_in_proc_frame_dispose (GimpPlugInProcFrame *proc_frame,
if (proc_frame->context_stack)
{
g_list_foreach (proc_frame->context_stack, (GFunc) g_object_unref, NULL);
g_list_free (proc_frame->context_stack);
g_list_free_full (proc_frame->context_stack,
(GDestroyNotify) g_object_unref);
proc_frame->context_stack = NULL;
}
......
......@@ -212,8 +212,7 @@ plug_in_rc_parse (Gimp *gimp,
_("fatal parse error"), TRUE);
}
g_slist_foreach (plug_in_defs, (GFunc) g_object_unref, NULL);
g_slist_free (plug_in_defs);
g_slist_free_full (plug_in_defs, (GDestroyNotify) g_object_unref);
plug_in_defs = NULL;
}
......
......@@ -224,8 +224,7 @@ gimp_tools_exit (Gimp *gimp)
default_order = g_object_get_data (G_OBJECT (gimp),
"gimp-tools-default-order");
g_list_foreach (default_order, (GFunc) g_free, NULL);
g_list_free (default_order);
g_list_free_full (default_order, (GDestroyNotify) g_free);
g_object_set_data (G_OBJECT (gimp), "gimp-tools-default-order", NULL);
......
......@@ -332,8 +332,7 @@ gimp_stroke_finalize (GObject *object)
if (stroke->anchors)
{
g_list_foreach (stroke->anchors, (GFunc) gimp_anchor_free, NULL);
g_list_free (stroke->anchors);
g_list_free_full (stroke->anchors, (GDestroyNotify) gimp_anchor_free);
stroke->anchors = NULL;
}
......
......@@ -268,8 +268,7 @@ gimp_vectors_finalize (GObject *object)
if (vectors->strokes)
{
g_list_foreach (vectors->strokes, (GFunc) g_object_unref, NULL);
g_list_free (vectors->strokes);
g_list_free_full (vectors->strokes, (GDestroyNotify) g_object_unref);
vectors->strokes = NULL;
}
......@@ -697,8 +696,7 @@ gimp_vectors_copy_strokes (const GimpVectors *src_vectors,
if (dest_vectors->strokes)
{
g_list_foreach (dest_vectors->strokes, (GFunc) g_object_unref, NULL);
g_list_free (dest_vectors->strokes);
g_list_free_full (dest_vectors->strokes, (GDestroyNotify) g_object_unref);
}
dest_vectors->strokes = NULL;
......
......@@ -757,8 +757,7 @@ gimp_container_icon_view_get_selected_single (GimpContainerIconView *icon_view,
retval = FALSE;
}
g_list_foreach (selected_items, (GFunc) gtk_tree_path_free, NULL);
g_list_free (selected_items);
g_list_free_full (selected_items, (GDestroyNotify) gtk_tree_path_free);
return retval;
}
......@@ -803,8 +802,7 @@ gimp_container_icon_view_get_selected (GimpContainerView *view,
*items = g_list_reverse (*items);
}
g_list_foreach (selected_items, (GFunc) gtk_tree_path_free, NULL);
g_list_free (selected_items);
g_list_free_full (selected_items, (GDestroyNotify) gtk_tree_path_free);
return selected_count;
}
......@@ -401,8 +401,7 @@ gimp_container_tree_view_drag_data_received (GtkWidget *widget,
tree_view_class->drop_uri_list (tree_view, uri_list,
dest_viewable, drop_pos);
g_list_foreach (uri_list, (GFunc) g_free, NULL);
g_list_free (uri_list);
g_list_free_full (uri_list, (GDestroyNotify) g_free);
success = TRUE;
}
......
......@@ -1264,8 +1264,7 @@ gimp_container_tree_view_get_selected_single (GimpContainerTreeView *tree_view,
gtk_tree_model_get_iter (GTK_TREE_MODEL (tree_view->model), iter,
(GtkTreePath *) selected_rows->data);
g_list_foreach (selected_rows, (GFunc) gtk_tree_path_free, NULL);
g_list_free (selected_rows);
g_list_free_full (selected_rows, (GDestroyNotify) gtk_tree_path_free);
return TRUE;
}
......@@ -1316,8 +1315,7 @@ gimp_container_tree_view_get_selected (GimpContainerView *view,
g_object_unref (renderer);
}
g_list_foreach (selected_rows, (GFunc) gtk_tree_path_free, NULL);
g_list_free (selected_rows);
g_list_free_full (selected_rows, (GDestroyNotify) gtk_tree_path_free);
*items = g_list_reverse (*items);
......
......@@ -190,8 +190,8 @@ gimp_dialog_factory_dispose (GObject *object)
if (factory->p->session_infos)
{
g_list_foreach (factory->p->session_infos, (GFunc) g_object_unref, NULL);
g_list_free (factory->p->session_infos);
g_list_free_full (factory->p->session_infos,
(GDestroyNotify) g_object_unref);
factory->p->session_infos = NULL;
}
......
......@@ -1053,8 +1053,7 @@ gimp_dnd_get_uri_list_data (GtkWidget *widget,
{
gimp_selection_data_set_uri_list (selection, uri_list);
g_list_foreach (uri_list, (GFunc) g_free, NULL);
g_list_free (uri_list);
g_list_free_full (uri_list, (GDestroyNotify) g_free);
}
}
......@@ -1074,8 +1073,7 @@ gimp_dnd_set_uri_list_data (GtkWidget *widget,
(* (GimpDndDropUriListFunc) set_uri_list_func) (widget, x, y, uri_list,
set_uri_list_data);
g_list_foreach (uri_list, (GFunc) g_free, NULL);
g_list_free (uri_list);
g_list_free_full (uri_list, (GDestroyNotify) g_free);
return TRUE;
}
......
......@@ -96,8 +96,7 @@ gimp_file_proc_view_finalize (GObject *object)
if (view->meta_extensions)
{
g_list_foreach (view->meta_extensions, (GFunc) g_free, NULL);
g_list_free (view->meta_extensions);
g_list_free_full (view->meta_extensions, (GDestroyNotify) g_free);
view->meta_extensions = NULL;
}
......
......@@ -152,8 +152,7 @@ gimp_icon_picker_constructed (GObject *object)
GIMP_TEMPLATE (object));
}
g_slist_foreach (stock_list, (GFunc) g_free, NULL);
g_slist_free (stock_list);
g_slist_free_full (stock_list, (GDestroyNotify) g_free);
button = gimp_viewable_button_new (private->stock_id_container,
private->stock_id_context,
......
......@@ -82,8 +82,7 @@ gimp_menu_factory_finalize (GObject *object)
g_free (entry->identifier);
g_list_foreach (entry->action_groups, (GFunc) g_free, NULL);
g_list_free (entry->action_groups);
g_list_free_full (entry->action_groups, (GDestroyNotify) g_free);
for (uis = entry->managed_uis; uis; uis = g_list_next (uis))
{
......
......@@ -272,8 +272,7 @@ gimp_selection_data_get_uri_list (GtkSelectionData *selection)
uri_list = g_list_prepend (uri_list, uri);
}
g_list_foreach (crap_list, (GFunc) g_free, NULL);
g_list_free (crap_list);
g_list_free_full (crap_list, (GDestroyNotify) g_free);
return uri_list;
}
......
......@@ -59,9 +59,8 @@ gimp_session_info_book_free (GimpSessionInfoBook *info)
if (info->dockables)
{
g_list_foreach (info->dockables, (GFunc) gimp_session_info_dockable_free,
NULL);
g_list_free (info->dockables);
g_list_free_full (info->dockables,
(GDestroyNotify) gimp_session_info_dockable_free);
info->dockables = NULL;
}
......
......@@ -69,10 +69,8 @@ gimp_session_info_dock_free (GimpSessionInfoDock *dock_info)
if (dock_info->books)
{
g_list_foreach (dock_info->books,
(GFunc) gimp_session_info_book_free,
NULL);
g_list_free (dock_info->books);
g_list_free_full (dock_info->books,
(GDestroyNotify) gimp_session_info_book_free);
dock_info->books = NULL;
}
......
......@@ -66,8 +66,8 @@ gimp_session_info_dockable_free (GimpSessionInfoDockable *info)
if (info->aux_info)
{
g_list_foreach (info->aux_info, (GFunc) gimp_session_info_aux_free, NULL);
g_list_free (info->aux_info);
g_list_free_full (info->aux_info,
(GDestroyNotify) gimp_session_info_aux_free);
info->aux_info = NULL;
}
......
......@@ -740,17 +740,15 @@ gimp_session_info_clear_info (GimpSessionInfo *info)
if (info->p->aux_info)
{
g_list_foreach (info->p->aux_info,
(GFunc) gimp_session_info_aux_free, NULL);
g_list_free (info->p->aux_info);
g_list_free_full (info->p->aux_info,
(GDestroyNotify) gimp_session_info_aux_free);
info->p->aux_info = NULL;
}
if (info->p->docks)
{
g_list_foreach (info->p->docks,
(GFunc) gimp_session_info_dock_free, NULL);
g_list_free (info->p->docks);
g_list_free_full (info->p->docks,
(GDestroyNotify) gimp_session_info_dock_free);
info->p->docks = NULL;
}
}
......
......@@ -231,8 +231,7 @@ gimp_tag_entry_dispose (GObject *object)
if (entry->recent_list)
{
g_list_foreach (entry->recent_list, (GFunc) g_free, NULL);
g_list_free (entry->recent_list);
g_list_free_full (entry->recent_list, (GDestroyNotify) g_free);
entry->recent_list = NULL;
}
......
......@@ -552,8 +552,7 @@ parse_info_free (ParseInfo *info)
g_slist_free (info->tag_stack);
g_slist_free (info->states);
g_list_foreach (info->spans, (GFunc) text_span_free, NULL);
g_list_free (info->spans);
g_list_free_full (info->spans, (GDestroyNotify) text_span_free);
}
static void
......
......@@ -480,8 +480,7 @@ gimp_thumb_box_take_uris (GimpThumbBox *box,
if (box->uris)
{
g_slist_foreach (box->uris, (GFunc) g_free, NULL);
g_slist_free (box->uris);
g_slist_free_full (box->uris, (GDestroyNotify) g_free);
box->uris = NULL;
}
......
......@@ -732,8 +732,7 @@ gimp_path_to_str (GList *path)
void
gimp_path_free (GList *path)
{
g_list_foreach (path, (GFunc) g_free, NULL);
g_list_free (path);
g_list_free_full (path, (GDestroyNotify) g_free);
}
/**
......
......@@ -988,8 +988,7 @@ gimp_page_selector_get_selected_pages (GimpPageSelector *selector,
qsort (array, *n_selected_pages, sizeof (gint),
gimp_page_selector_int_compare);
g_list_foreach (selected, (GFunc) gtk_tree_path_free, NULL);
g_list_free (selected);
g_list_free_full (selected, (GDestroyNotify) gtk_tree_path_free);
return array;
}
......@@ -1167,8 +1166,7 @@ gimp_page_selector_selection_changed (GtkIconView *icon_view,
selected = gtk_icon_view_get_selected_items (GTK_ICON_VIEW (priv->view));
n_selected = g_list_length (selected);
g_list_foreach (selected, (GFunc) gtk_tree_path_free, NULL);
g_list_free (selected);
g_list_free_full (selected, (GDestroyNotify) gtk_tree_path_free);
if (n_selected == 0)
{
......
......@@ -98,8 +98,7 @@ gimp_widgets_init (GimpHelpFunc standard_help_func,
gtk_window_set_default_icon_list (icon_list);
g_list_foreach (icon_list, (GFunc) g_object_unref, NULL);
g_list_free (icon_list);
g_list_free_full (icon_list, (GDestroyNotify) g_object_unref);
gimp_widgets_init_foreign_enums ();
......
......@@ -905,13 +905,11 @@ dicom_add_element_int (GSList *elements,
/**
* dicom_element_done:
* @data: pointer to a DICOMELEMENT structure which is to be destroyed.
* @user_data: unused.
*
* Destroys the DICOMELEMENT passed as @data
**/
static void
dicom_element_done (gpointer data,
gpointer user_data)
dicom_element_done (gpointer data)
{
if (data)
{
......@@ -934,10 +932,7 @@ static void
dicom_elements_destroy (GSList *elements)
{
if (elements)
{
g_slist_foreach (elements, dicom_element_done, NULL);
g_slist_free (elements);
}
g_slist_free_full (elements, dicom_element_done);
}
/**
......
......@@ -907,8 +907,7 @@ fractalexplorer_free_everything (fractalexplorerOBJ *fractalexplorer)
static void
fractalexplorer_list_free_all (void)
{
g_list_foreach (fractalexplorer_list, (GFunc) fractalexplorer_free, NULL);
g_list_free (fractalexplorer_list);
g_list_free_full (fractalexplorer_list, (GDestroyNotify) fractalexplorer_free);
fractalexplorer_list = NULL;
}
......
......@@ -837,8 +837,7 @@ gfig_list_load_all (const gchar *path)
static void
gfig_list_free_all (void)
{
g_list_foreach (gfig_list, (GFunc) gfig_free, NULL);
g_list_free (gfig_list);
g_list_free_full (gfig_list, (GDestroyNotify) gfig_free);
gfig_list = NULL;
}
......
......@@ -913,10 +913,9 @@ free_one_obj (GfigObject *obj)
}
void
free_all_objs (GList * objs)
free_all_objs (GList *objs)
{
g_list_foreach (objs, (GFunc)free_one_obj, NULL);
g_list_free (objs);
g_list_free_full (objs, (GDestroyNotify) free_one_obj);
}
gchar *
......
......@@ -160,20 +160,13 @@ parsepath (void)
return parsepath_cached_path;
}
static void
my_g_free (gpointer data, gpointer userdata)
{
g_free (data);
}
void
free_parsepath_cache (void)
{
if (parsepath_cached_path != NULL)
return;
g_list_foreach (parsepath_cached_path, my_g_free, NULL);
g_list_free (parsepath_cached_path);
g_list_free_full (parsepath_cached_path, (GDestroyNotify) g_free);
parsepath_cached_path = NULL;
}
......
......@@ -1657,8 +1657,7 @@ gflares_list_load_all (void)
static void
gflares_list_free_all (void)
{
g_list_foreach (gflares_list, (GFunc) gflare_free, NULL);
g_list_free (gflares_list);
g_list_free_full (gflares_list, (GDestroyNotify) gflare_free);
gflares_list = NULL;
}
......@@ -1971,8 +1970,7 @@ calc_deinit (void)
return;
}
g_list_foreach (calc.sflare_list, (GFunc) g_free, NULL);
g_list_free (calc.sflare_list);
g_list_free_full (calc.sflare_list, (GDestroyNotify) g_free);
g_free (calc.glow_radial);
g_free (calc.glow_angular);
......
......@@ -355,8 +355,8 @@ window_set_icons (GtkWidget *window)
sizes[i], NULL));
gtk_window_set_icon_list (GTK_WINDOW (window), list);
g_list_foreach (list, (GFunc) g_object_unref, NULL);
g_list_free (list);
g_list_free_full (list, (GDestroyNotify) g_object_unref);