Commit 9f24b547 authored by Matthias Clasen's avatar Matthias Clasen

Code cleanup

Use g_slist_free_full more consistently. This commit just converts
the obvious cases where g_slist_forall is directly followed by
g_slist_free.
parent 9dd2645c
......@@ -2192,9 +2192,7 @@ gdk_error_trap_push (void)
g_slist_foreach (trap->displays, (GFunc) g_object_ref, NULL);
for (l = trap->displays; l != NULL; l = l->next)
{
class->push_error_trap (l->data);
}
class->push_error_trap (l->data);
g_queue_push_head (&gdk_error_traps, trap);
}
......
......@@ -159,8 +159,7 @@ free_startup_timeout (void *data)
std = data;
g_slist_foreach (std->contexts, (GFunc) free_startup_notification_data, NULL);
g_slist_free (std->contexts);
g_slist_free_full (std->contexts, free_startup_notification_data);
if (std->timeout_id != 0)
{
......
......@@ -1948,8 +1948,7 @@ gdk_x11_display_finalize (GObject *object)
XDestroyWindow (display_x11->xdisplay, display_x11->leader_window);
/* List of event window extraction functions */
g_slist_foreach (display_x11->event_types, (GFunc)g_free, NULL);
g_slist_free (display_x11->event_types);
g_slist_free_full (display_x11->event_types, g_free);
/* input GdkDevice list */
g_list_free_full (display_x11->input_devices, g_object_unref);
......
......@@ -1018,11 +1018,8 @@ gtk_rc_style_finalize (GObject *object)
rc_style->rc_properties = NULL;
}
g_slist_foreach (rc_style->icon_factories, (GFunc) g_object_unref, NULL);
g_slist_free (rc_style->icon_factories);
g_slist_foreach (rc_priv->color_hashes, (GFunc) g_hash_table_unref, NULL);
g_slist_free (rc_priv->color_hashes);
g_slist_free_full (rc_style->icon_factories, g_object_unref);
g_slist_free_full (rc_priv->color_hashes, (GDestroyNotify)g_hash_table_unref);
G_OBJECT_CLASS (gtk_rc_style_parent_class)->finalize (object);
}
......
......@@ -542,8 +542,7 @@ gtk_style_finalize (GObject *object)
}
}
g_slist_foreach (style->icon_factories, (GFunc) g_object_unref, NULL);
g_slist_free (style->icon_factories);
g_slist_free_full (style->icon_factories, g_object_unref);
pango_font_description_free (style->font_desc);
......@@ -1108,8 +1107,7 @@ gtk_style_real_copy (GtkStyle *style,
if (src->rc_style)
g_object_ref (src->rc_style);
g_slist_foreach (style->icon_factories, (GFunc) g_object_unref, NULL);
g_slist_free (style->icon_factories);
g_slist_free_full (style->icon_factories, g_object_unref);
style->icon_factories = g_slist_copy (src->icon_factories);
g_slist_foreach (style->icon_factories, (GFunc) g_object_ref, NULL);
}
......
......@@ -787,9 +787,7 @@ gtk_about_dialog_finalize (GObject *object)
g_strfreev (priv->artists);
g_slist_free_full (priv->credit_sections, destroy_credit_section);
g_slist_foreach (priv->visited_links, (GFunc)g_free, NULL);
g_slist_free (priv->visited_links);
g_slist_free_full (priv->visited_links, g_free);
G_OBJECT_CLASS (gtk_about_dialog_parent_class)->finalize (object);
}
......@@ -1931,8 +1929,7 @@ follow_if_link (GtkAboutDialog *about,
}
}
if (tags)
g_slist_free (tags);
g_slist_free (tags);
}
static gboolean
......@@ -2034,8 +2031,7 @@ set_cursor_if_appropriate (GtkAboutDialog *about,
gdk_window_set_device_cursor (gtk_text_view_get_window (text_view, GTK_TEXT_WINDOW_TEXT), device, priv->regular_cursor);
}
if (tags)
g_slist_free (tags);
g_slist_free (tags);
}
static gboolean
......
......@@ -31,8 +31,10 @@
#include "gtkfilechooser.h" /* for the GError types */
static void
_gtk_bookmark_free (GtkBookmark *bookmark)
_gtk_bookmark_free (gpointer data)
{
GtkBookmark *bookmark = data;
g_object_unref (bookmark->file);
g_free (bookmark->label);
g_slice_free (GtkBookmark, bookmark);
......@@ -197,9 +199,7 @@ bookmarks_file_changed (GFileMonitor *monitor,
case G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT:
case G_FILE_MONITOR_EVENT_CREATED:
case G_FILE_MONITOR_EVENT_DELETED:
g_slist_foreach (manager->bookmarks, (GFunc) _gtk_bookmark_free, NULL);
g_slist_free (manager->bookmarks);
g_slist_free_full (manager->bookmarks, _gtk_bookmark_free);
manager->bookmarks = read_bookmarks (file);
gdk_threads_enter ();
......@@ -271,11 +271,7 @@ _gtk_bookmarks_manager_free (GtkBookmarksManager *manager)
g_object_unref (manager->bookmarks_monitor);
}
if (manager->bookmarks)
{
g_slist_foreach (manager->bookmarks, (GFunc) _gtk_bookmark_free, NULL);
g_slist_free (manager->bookmarks);
}
g_slist_free_full (manager->bookmarks, _gtk_bookmark_free);
g_free (manager);
}
......
......@@ -319,8 +319,7 @@ gtk_builder_finalize (GObject *object)
if (priv->callbacks)
g_hash_table_destroy (priv->callbacks);
g_slist_foreach (priv->signals, (GFunc) _free_signal_info, NULL);
g_slist_free (priv->signals);
g_slist_free_full (priv->signals, (GDestroyNotify)_free_signal_info);
G_OBJECT_CLASS (gtk_builder_parent_class)->finalize (object);
}
......@@ -1734,8 +1733,7 @@ gtk_builder_connect_signals_full (GtkBuilder *builder,
connect_object, signal->flags, user_data);
}
g_slist_foreach (builder->priv->signals, (GFunc)_free_signal_info, NULL);
g_slist_free (builder->priv->signals);
g_slist_free_full (builder->priv->signals, (GDestroyNotify)_free_signal_info);
builder->priv->signals = NULL;
if (detailed_id)
......
......@@ -512,9 +512,7 @@ free_object_info (ObjectInfo *info)
{
/* Do not free the signal items, which GtkBuilder takes ownership of */
g_slist_free (info->signals);
g_slist_foreach (info->properties,
(GFunc)free_property_info, NULL);
g_slist_free (info->properties);
g_slist_free_full (info->properties, (GDestroyNotify)free_property_info);
g_free (info->constructor);
g_free (info->id);
g_slice_free (ObjectInfo, info);
......@@ -1343,13 +1341,10 @@ _gtk_builder_parser_parse_buffer (GtkBuilder *builder,
out:
g_slist_foreach (data->stack, (GFunc)free_info, NULL);
g_slist_free (data->stack);
g_slist_foreach (data->custom_finalizers, (GFunc)free_subparser, NULL);
g_slist_free (data->custom_finalizers);
g_slist_free_full (data->stack, (GDestroyNotify)free_info);
g_slist_free_full (data->custom_finalizers, (GDestroyNotify)free_subparser);
g_slist_free (data->finalizers);
g_slist_foreach (data->requested_objects, (GFunc) g_free, NULL);
g_slist_free (data->requested_objects);
g_slist_free_full (data->requested_objects, g_free);
g_free (data->domain);
g_hash_table_destroy (data->object_ids);
g_markup_parse_context_free (data->ctx);
......
......@@ -858,8 +858,7 @@ cell_info_free (CellInfo *info)
if (info->destroy)
info->destroy (info->data);
g_slist_foreach (info->attributes, (GFunc)cell_attribute_free, NULL);
g_slist_free (info->attributes);
g_slist_free_full (info->attributes, (GDestroyNotify)cell_attribute_free);
g_slice_free (CellInfo, info);
}
......@@ -1540,9 +1539,7 @@ gtk_cell_area_clear_attributes (GtkCellLayout *cell_layout,
if (info)
{
g_slist_foreach (info->attributes, (GFunc)cell_attribute_free, NULL);
g_slist_free (info->attributes);
g_slist_free_full (info->attributes, (GDestroyNotify)cell_attribute_free);
info->attributes = NULL;
}
}
......
......@@ -1292,16 +1292,15 @@ gtk_cell_area_box_foreach_alloc (GtkCellArea *area,
break;
}
g_slist_foreach (allocated_cells, (GFunc)allocated_cell_free, NULL);
g_slist_free (allocated_cells);
g_slist_free_full (allocated_cells, (GDestroyNotify)allocated_cell_free);
}
static void
gtk_cell_area_box_apply_attributes (GtkCellArea *area,
GtkTreeModel *tree_model,
GtkTreeIter *iter,
gboolean is_expander,
gboolean is_expanded)
gtk_cell_area_box_apply_attributes (GtkCellArea *area,
GtkTreeModel *tree_model,
GtkTreeIter *iter,
gboolean is_expander,
gboolean is_expanded)
{
GtkCellAreaBox *box = GTK_CELL_AREA_BOX (area);
GtkCellAreaBoxPrivate *priv = box->priv;
......@@ -1309,7 +1308,7 @@ gtk_cell_area_box_apply_attributes (GtkCellArea *area,
/* Call the parent class to apply the attributes */
GTK_CELL_AREA_CLASS
(gtk_cell_area_box_parent_class)->apply_attributes (area, tree_model, iter,
(gtk_cell_area_box_parent_class)->apply_attributes (area, tree_model, iter,
is_expander, is_expanded);
/* Update visible state for cell groups */
......
......@@ -873,8 +873,7 @@ gtk_file_chooser_get_filenames (GtkFileChooser *chooser)
files = gtk_file_chooser_get_files (chooser);
result = files_to_strings (files, g_file_get_path);
g_slist_foreach (files, (GFunc) g_object_unref, NULL);
g_slist_free (files);
g_slist_free_full (files, g_object_unref);
return result;
}
......@@ -1218,8 +1217,7 @@ gtk_file_chooser_get_uris (GtkFileChooser *chooser)
else
result = files_to_strings (files, g_file_get_uri);
g_slist_foreach (files, (GFunc) g_object_unref, NULL);
g_slist_free (files);
g_slist_free_full (files, g_object_unref);
return result;
}
......@@ -1498,8 +1496,7 @@ gtk_file_chooser_get_file (GtkFileChooser *chooser)
result = list->data;
list = g_slist_delete_link (list, list);
g_slist_foreach (list, (GFunc) g_object_unref, NULL);
g_slist_free (list);
g_slist_free_full (list, g_object_unref);
}
return result;
......@@ -2064,8 +2061,7 @@ gtk_file_chooser_list_shortcut_folders (GtkFileChooser *chooser)
folders = _gtk_file_chooser_list_shortcut_folder_files (chooser);
result = files_to_strings (folders, g_file_get_path);
g_slist_foreach (folders, (GFunc) g_object_unref, NULL);
g_slist_free (folders);
g_slist_free_full (folders, g_object_unref);
return result;
}
......@@ -2161,8 +2157,7 @@ gtk_file_chooser_list_shortcut_folder_uris (GtkFileChooser *chooser)
folders = _gtk_file_chooser_list_shortcut_folder_files (chooser);
result = files_to_strings (folders, g_file_get_uri);
g_slist_foreach (folders, (GFunc) g_object_unref, NULL);
g_slist_free (folders);
g_slist_free_full (folders, g_object_unref);
return result;
}
......
......@@ -839,8 +839,7 @@ G_GNUC_END_IGNORE_DEPRECATIONS
list = _gtk_bookmarks_manager_list_bookmarks (priv->bookmarks_manager);
model_add_bookmarks (button, list);
g_slist_foreach (list, (GFunc) g_object_unref, NULL);
g_slist_free (list);
g_slist_free_full (list, g_object_unref);
model_add_other (button);
......@@ -2625,14 +2624,12 @@ bookmarks_changed_cb (gpointer user_data)
bookmarks = _gtk_bookmarks_manager_list_bookmarks (priv->bookmarks_manager);
model_remove_rows (user_data,
model_get_type_position (user_data,
ROW_TYPE_BOOKMARK_SEPARATOR),
(priv->n_bookmarks + priv->has_bookmark_separator));
model_get_type_position (user_data, ROW_TYPE_BOOKMARK_SEPARATOR),
priv->n_bookmarks + priv->has_bookmark_separator);
priv->has_bookmark_separator = FALSE;
priv->n_bookmarks = 0;
model_add_bookmarks (user_data, bookmarks);
g_slist_foreach (bookmarks, (GFunc) g_object_unref, NULL);
g_slist_free (bookmarks);
g_slist_free_full (bookmarks, g_object_unref);
gtk_tree_model_filter_refilter (GTK_TREE_MODEL_FILTER (priv->filter_model));
......
......@@ -424,8 +424,7 @@ file_chooser_widget_selection_changed (GtkWidget *widget,
sensitive = (uris != NULL);
gtk_widget_set_sensitive (button, sensitive);
if (uris)
g_slist_free_full (uris, g_free);
g_slist_free_full (uris, g_free);
}
static void
......
......@@ -1744,8 +1744,7 @@ visit_file_cb (GSimpleAction *action,
gtk_file_chooser_widget_select_file (GTK_FILE_CHOOSER (impl), file, NULL); /* NULL-GError */
}
g_slist_foreach (files, (GFunc) g_object_unref, NULL);
g_slist_free (files);
g_slist_free_full (files, g_object_unref);
}
/* Callback used when the "Open this folder" menu item is activated */
......@@ -1770,8 +1769,7 @@ open_folder_cb (GSimpleAction *action,
g_free (uri);
}
g_slist_foreach (files, (GFunc) g_object_unref, NULL);
g_slist_free (files);
g_slist_free_full (files, g_object_unref);
}
/* callback used when the "Show Hidden Files" menu item is toggled */
......@@ -6694,8 +6692,7 @@ add_selection_to_recent_list (GtkFileChooserWidget *impl)
}
}
g_slist_foreach (files, (GFunc) g_object_unref, NULL);
g_slist_free (files);
g_slist_free_full (files, g_object_unref);
}
static gboolean
......
......@@ -187,8 +187,7 @@ gtk_file_filter_finalize (GObject *object)
{
GtkFileFilter *filter = GTK_FILE_FILTER (object);
g_slist_foreach (filter->rules, (GFunc)filter_rule_free, NULL);
g_slist_free (filter->rules);
g_slist_free_full (filter->rules, (GDestroyNotify)filter_rule_free);
g_free (filter->name);
......
......@@ -120,8 +120,7 @@ gtk_file_system_dispose (GObject *object)
if (priv->volumes)
{
g_slist_foreach (priv->volumes, (GFunc) g_object_unref, NULL);
g_slist_free (priv->volumes);
g_slist_free_full (priv->volumes, g_object_unref);
priv->volumes = NULL;
}
......@@ -199,8 +198,7 @@ get_volumes_list (GtkFileSystem *file_system)
if (priv->volumes)
{
g_slist_foreach (priv->volumes, (GFunc) g_object_unref, NULL);
g_slist_free (priv->volumes);
g_slist_free_full (priv->volumes, g_object_unref);
priv->volumes = NULL;
}
......
......@@ -138,13 +138,8 @@ gtk_im_context_simple_finalize (GObject *obj)
GtkIMContextSimple *context_simple = GTK_IM_CONTEXT_SIMPLE (obj);
GtkIMContextSimplePrivate *priv = context_simple->priv;
if (priv->tables)
{
g_slist_foreach (priv->tables, (GFunc)g_free, NULL);
g_slist_free (priv->tables);
priv->tables = NULL;
}
g_slist_free_full (priv->tables, g_free);
priv->tables = NULL;
G_OBJECT_CLASS (gtk_im_context_simple_parent_class)->finalize (obj);
}
......
......@@ -490,14 +490,7 @@ G_GNUC_END_IGNORE_DEPRECATIONS
if (have_error)
{
GSList *tmp_list = infos;
while (tmp_list)
{
free_info (tmp_list->data);
tmp_list = tmp_list->next;
}
g_slist_free (infos);
g_slist_free_full (infos, (GDestroyNotify)free_info);
g_object_unref (module);
}
else if (module)
......
......@@ -1220,8 +1220,7 @@ update_places (GtkPlacesSidebar *sidebar)
clos);
}
g_slist_foreach (bookmarks, (GFunc) g_object_unref, NULL);
g_slist_free (bookmarks);
g_slist_free_full (bookmarks, g_object_unref);
/* Add new bookmark row */
new_bookmark_icon = g_themed_icon_new ("bookmark-new-symbolic");
......
......@@ -591,8 +591,7 @@ gtk_recent_chooser_default_dispose (GObject *object)
if (impl->priv->filters)
{
g_slist_foreach (impl->priv->filters, (GFunc) g_object_unref, NULL);
g_slist_free (impl->priv->filters);
g_slist_free_full (impl->priv->filters, g_object_unref);
impl->priv->filters = NULL;
}
......
......@@ -1497,11 +1497,7 @@ gtk_recent_info_free (GtkRecentInfo *recent_info)
if (recent_info->applications)
{
g_slist_foreach (recent_info->applications,
(GFunc) recent_app_info_free,
NULL);
g_slist_free (recent_info->applications);
g_slist_free_full (recent_info->applications, (GDestroyNotify)recent_app_info_free);
recent_info->applications = NULL;
}
......@@ -1510,11 +1506,7 @@ gtk_recent_info_free (GtkRecentInfo *recent_info)
if (recent_info->groups)
{
g_slist_foreach (recent_info->groups,
(GFunc) g_free,
NULL);
g_slist_free (recent_info->groups);
g_slist_free_full (recent_info->groups, g_free);
recent_info->groups = NULL;
}
......
......@@ -2848,9 +2848,7 @@ gtk_text_buffer_remove_all_tags (GtkTextBuffer *buffer,
tmp_list = tmp_list->next;
}
g_slist_foreach (tags, (GFunc) g_object_unref, NULL);
g_slist_free (tags);
g_slist_free_full (tags, g_object_unref);
}
......
......@@ -345,7 +345,6 @@ static void
gtk_text_child_anchor_finalize (GObject *obj)
{
GtkTextChildAnchor *anchor;
GSList *tmp_list;
GtkTextLineSegment *seg;
anchor = GTK_TEXT_CHILD_ANCHOR (obj);
......@@ -361,15 +360,8 @@ gtk_text_child_anchor_finalize (GObject *obj)
"and the refcount is 0.");
return;
}
tmp_list = seg->body.child.widgets;
while (tmp_list)
{
g_object_unref (tmp_list->data);
tmp_list = g_slist_next (tmp_list);
}
g_slist_free (seg->body.child.widgets);
g_slist_free_full (seg->body.child.widgets, g_object_unref);
g_slice_free1 (WIDGET_SEG_SIZE, seg);
}
......
......@@ -15516,8 +15516,7 @@ static gboolean
tooltip_query_idle (gpointer data)
{
g_slist_foreach (tooltip_query_displays, (GFunc)gtk_tooltip_trigger_tooltip_query, NULL);
g_slist_foreach (tooltip_query_displays, (GFunc)g_object_unref, NULL);
g_slist_free (tooltip_query_displays);
g_slist_free_full (tooltip_query_displays, g_object_unref);
tooltip_query_displays = NULL;
tooltip_query_id = 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment