[gtk+] gtk/*: Use g_list_free_full() convenience function



commit d005b013196bc8b69474f718a5817baf9aec99af
Author: Javier JardÃn <jjardon gnome org>
Date:   Mon Jan 2 04:20:59 2012 +0100

    gtk/*: Use g_list_free_full() convenience function

 gtk/gtkdnd.c                  |    3 +--
 gtk/gtkfilechooserdefault.c   |    3 +--
 gtk/gtkicontheme.c            |   12 ++++--------
 gtk/gtkiconview.c             |    6 ++----
 gtk/gtklabel.c                |    6 ++----
 gtk/gtkpapersize.c            |    3 +--
 gtk/gtkprintunixdialog.c      |    3 +--
 gtk/gtkquery.c                |    3 +--
 gtk/gtkrecentchooser.c        |    5 +----
 gtk/gtkrecentchooserdefault.c |   13 +++----------
 gtk/gtkrecentchoosermenu.c    |    3 +--
 gtk/gtkrecentchooserutils.c   |    3 +--
 gtk/gtksearchenginesimple.c   |    3 +--
 gtk/gtkstylecontext.c         |    9 +++------
 gtk/gtktextbufferrichtext.c   |    3 +--
 gtk/gtktextbufferserialize.c  |    6 ++----
 gtk/gtktreeview.c             |    3 +--
 gtk/gtkuimanager.c            |    7 ++-----
 gtk/gtkwidget.c               |    6 ++----
 gtk/gtkwindow.c               |   21 +++++----------------
 gtk/updateiconcache.c         |    3 +--
 21 files changed, 37 insertions(+), 87 deletions(-)
---
diff --git a/gtk/gtkdnd.c b/gtk/gtkdnd.c
index ac33fd8..3891179 100644
--- a/gtk/gtkdnd.c
+++ b/gtk/gtkdnd.c
@@ -2003,8 +2003,7 @@ gtk_drag_find_widget (GtkWidget           *widget,
             g_object_add_weak_pointer (G_OBJECT (parent), (gpointer *) &parent);
         }
 
-      g_list_foreach (hierarchy, (GFunc) g_object_unref, NULL);
-      g_list_free (hierarchy);
+      g_list_free_full (hierarchy, g_object_unref);
 
       if (found)
         return TRUE;
diff --git a/gtk/gtkfilechooserdefault.c b/gtk/gtkfilechooserdefault.c
index 280e491..f08d36b 100644
--- a/gtk/gtkfilechooserdefault.c
+++ b/gtk/gtkfilechooserdefault.c
@@ -820,8 +820,7 @@ shortcuts_free (GtkFileChooserDefault *impl)
 static void
 pending_select_files_free (GtkFileChooserDefault *impl)
 {
-  g_slist_foreach (impl->pending_select_files, (GFunc) g_object_unref, NULL);
-  g_slist_free (impl->pending_select_files);
+  g_slist_free_full (impl->pending_select_files, g_object_unref);
   impl->pending_select_files = NULL;
 }
 
diff --git a/gtk/gtkicontheme.c b/gtk/gtkicontheme.c
index 66e03ad..4f86cc7 100644
--- a/gtk/gtkicontheme.c
+++ b/gtk/gtkicontheme.c
@@ -734,10 +734,8 @@ blow_themes (GtkIconTheme *icon_theme)
   if (priv->themes_valid)
     {
       g_hash_table_destroy (priv->all_icons);
-      g_list_foreach (priv->themes, (GFunc)theme_destroy, NULL);
-      g_list_free (priv->themes);
-      g_list_foreach (priv->dir_mtimes, (GFunc)free_dir_mtime, NULL);
-      g_list_free (priv->dir_mtimes);
+      g_list_free_full (priv->themes, (GDestroyNotify) theme_destroy);
+      g_list_free_full (priv->dir_mtimes, (GDestroyNotify) free_dir_mtime);
       g_hash_table_destroy (priv->unthemed_icons);
     }
   priv->themes = NULL;
@@ -2021,8 +2019,7 @@ theme_destroy (IconTheme *theme)
   g_free (theme->name);
   g_free (theme->example);
 
-  g_list_foreach (theme->dirs, (GFunc)theme_dir_destroy, NULL);
-  g_list_free (theme->dirs);
+  g_list_free_full (theme->dirs, (GDestroyNotify) theme_dir_destroy);
   
   g_free (theme);
 }
@@ -2721,8 +2718,7 @@ gtk_icon_info_free (GtkIconInfo *icon_info)
   g_free (icon_info->filename);
   if (icon_info->loadable)
     g_object_unref (icon_info->loadable);
-  g_slist_foreach (icon_info->emblem_infos, (GFunc)gtk_icon_info_free, NULL);
-  g_slist_free (icon_info->emblem_infos);
+  g_slist_free_full (icon_info->emblem_infos, (GDestroyNotify) gtk_icon_info_free);
   if (icon_info->pixbuf)
     g_object_unref (icon_info->pixbuf);
   if (icon_info->cache_pixbuf)
diff --git a/gtk/gtkiconview.c b/gtk/gtkiconview.c
index 79f94db..90069fc 100644
--- a/gtk/gtkiconview.c
+++ b/gtk/gtkiconview.c
@@ -4768,8 +4768,7 @@ gtk_icon_view_set_model (GtkIconView *icon_view,
 
       g_object_unref (icon_view->priv->model);
       
-      g_list_foreach (icon_view->priv->items, (GFunc)gtk_icon_view_item_free, NULL);
-      g_list_free (icon_view->priv->items);
+      g_list_free_full (icon_view->priv->items, (GDestroyNotify) gtk_icon_view_item_free);
       icon_view->priv->items = NULL;
       icon_view->priv->anchor_item = NULL;
       icon_view->priv->cursor_item = NULL;
@@ -5180,8 +5179,7 @@ gtk_icon_view_unselect_path (GtkIconView *icon_view,
  *
  * To free the return value, use:
  * |[
- * g_list_foreach (list, (GFunc)gtk_tree_path_free, NULL);
- * g_list_free (list);
+ * g_list_free_full (list, (GDestroyNotify) gtk_tree_patch_free);
  * ]|
  *
  * Return value: (element-type GtkTreePath) (transfer full): A #GList containing a #GtkTreePath for each selected row.
diff --git a/gtk/gtklabel.c b/gtk/gtklabel.c
index 589f20a..5ca9b1d 100644
--- a/gtk/gtklabel.c
+++ b/gtk/gtklabel.c
@@ -2509,8 +2509,7 @@ parse_uri_markup (GtkLabel     *label,
 failed:
   g_markup_parse_context_free (context);
   g_string_free (pdata.new_str, TRUE);
-  g_list_foreach (pdata.links, (GFunc)link_free, NULL);
-  g_list_free (pdata.links);
+  g_list_free_full (pdata.links, (GDestroyNotify) link_free);
   gdk_color_free (pdata.link_color);
   gdk_color_free (pdata.visited_link_color);
 
@@ -6267,8 +6266,7 @@ gtk_label_clear_links (GtkLabel *label)
   if (!priv->select_info)
     return;
 
-  g_list_foreach (priv->select_info->links, (GFunc)link_free, NULL);
-  g_list_free (priv->select_info->links);
+  g_list_free_full (priv->select_info->links, (GDestroyNotify) link_free);
   priv->select_info->links = NULL;
   priv->select_info->active_link = NULL;
 }
diff --git a/gtk/gtkpapersize.c b/gtk/gtkpapersize.c
index 06852c0..7ed892b 100644
--- a/gtk/gtkpapersize.c
+++ b/gtk/gtkpapersize.c
@@ -490,8 +490,7 @@ gtk_paper_size_get_paper_sizes (gboolean include_custom)
           list = g_list_prepend (list, gtk_paper_size_copy (size));
         }
 
-      g_list_foreach (page_setups, (GFunc) g_object_unref, NULL);
-      g_list_free (page_setups);
+      g_list_free_full (page_setups, g_object_unref);
     }
 #endif
   for (i = 0; i < G_N_ELEMENTS (standard_names_offsets); ++i)
diff --git a/gtk/gtkprintunixdialog.c b/gtk/gtkprintunixdialog.c
index 091109e..15fdaaf 100644
--- a/gtk/gtkprintunixdialog.c
+++ b/gtk/gtkprintunixdialog.c
@@ -1540,8 +1540,7 @@ update_dialog_from_settings (GtkPrintUnixDialog *dialog)
   else
     gtk_widget_hide (priv->advanced_page);
 
-  g_list_foreach (groups, (GFunc) g_free, NULL);
-  g_list_free (groups);
+  g_list_free_full (groups, g_free);
 }
 
 static void
diff --git a/gtk/gtkquery.c b/gtk/gtkquery.c
index 6b17c74..74879e0 100644
--- a/gtk/gtkquery.c
+++ b/gtk/gtkquery.c
@@ -121,8 +121,7 @@ _gtk_query_set_mime_types (GtkQuery *query,
   GList *l;
   gchar *mime_type;
 
-  g_list_foreach (query->priv->mime_types, (GFunc)g_free, NULL);
-  g_list_free (query->priv->mime_types);
+  g_list_free_full (query->priv->mime_types, g_free);
   query->priv->mime_types = NULL;
 
   for (l = mime_types; l; l = l->next)
diff --git a/gtk/gtkrecentchooser.c b/gtk/gtkrecentchooser.c
index b6873ec..81203e2 100644
--- a/gtk/gtkrecentchooser.c
+++ b/gtk/gtkrecentchooser.c
@@ -895,10 +895,7 @@ gtk_recent_chooser_get_uris (GtkRecentChooser *chooser,
   if (length)
     *length = i;
   
-  g_list_foreach (items,
-  		  (GFunc) gtk_recent_info_unref,
-  		  NULL);
-  g_list_free (items);
+  g_list_free_full (items, (GDestroyNotify) gtk_recent_info_unref);
   
   return retval;
 }
diff --git a/gtk/gtkrecentchooserdefault.c b/gtk/gtkrecentchooserdefault.c
index b524a90..88b3169 100644
--- a/gtk/gtkrecentchooserdefault.c
+++ b/gtk/gtkrecentchooserdefault.c
@@ -629,12 +629,8 @@ gtk_recent_chooser_default_dispose (GObject *object)
       impl->load_id = 0;
     }
 
-  if (impl->recent_items)
-    {
-      g_list_foreach (impl->recent_items, (GFunc) gtk_recent_info_unref, NULL);
-      g_list_free (impl->recent_items);
-      impl->recent_items = NULL;
-    }
+  g_list_free_full (impl->recent_items, (GDestroyNotify) gtk_recent_info_unref);
+  impl->recent_items = NULL;
 
   if (impl->manager && impl->manager_changed_id)
     {
@@ -839,10 +835,7 @@ load_recent_items (gpointer user_data)
       /* we have finished loading, so we remove the items cache */
       impl->load_state = LOAD_LOADING;
       
-      g_list_foreach (impl->recent_items,
-      		      (GFunc) gtk_recent_info_unref,
-      		      NULL);
-      g_list_free (impl->recent_items);
+      g_list_free_full (impl->recent_items, (GDestroyNotify) gtk_recent_info_unref);
       
       impl->recent_items = NULL;
       impl->n_recent_items = 0;
diff --git a/gtk/gtkrecentchoosermenu.c b/gtk/gtkrecentchoosermenu.c
index 4e88561..10eee3f 100644
--- a/gtk/gtkrecentchoosermenu.c
+++ b/gtk/gtkrecentchoosermenu.c
@@ -1055,8 +1055,7 @@ check_and_return:
 
   if (pdata->loaded_items == pdata->n_items)
     {
-      g_list_foreach (pdata->items, (GFunc) gtk_recent_info_unref, NULL);
-      g_list_free (pdata->items);
+      g_list_free_full (pdata->items, (GDestroyNotify) gtk_recent_info_unref);
 
       priv->populate_id = 0;
 
diff --git a/gtk/gtkrecentchooserutils.c b/gtk/gtkrecentchooserutils.c
index 54f0ff5..6425a0f 100644
--- a/gtk/gtkrecentchooserutils.c
+++ b/gtk/gtkrecentchooserutils.c
@@ -525,8 +525,7 @@ _gtk_recent_chooser_get_items (GtkRecentChooser  *chooser,
       l = clamp->next;
       clamp->next = NULL;
     
-      g_list_foreach (l, (GFunc) gtk_recent_info_unref, NULL);
-      g_list_free (l);
+      g_list_free_full (l, (GDestroyNotify) gtk_recent_info_unref);
     }
 
   return items;
diff --git a/gtk/gtksearchenginesimple.c b/gtk/gtksearchenginesimple.c
index 515dd68..55e8f7b 100644
--- a/gtk/gtksearchenginesimple.c
+++ b/gtk/gtksearchenginesimple.c
@@ -168,8 +168,7 @@ search_thread_add_hits_idle (gpointer user_data)
 				    hits->uris);
     }
 
-  g_list_foreach (hits->uris, (GFunc)g_free, NULL);
-  g_list_free (hits->uris);
+  g_list_free_full (hits->uris, g_free);
   g_free (hits);
 	
   return FALSE;
diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c
index 0a6b43c..ac48bc6 100644
--- a/gtk/gtkstylecontext.c
+++ b/gtk/gtkstylecontext.c
@@ -584,8 +584,7 @@ style_data_free (StyleData *data)
   g_object_unref (data->store);
   clear_property_cache (data);
 
-  g_slist_foreach (data->icon_factories, (GFunc) g_object_unref, NULL);
-  g_slist_free (data->icon_factories);
+  g_slist_free_full (data->icon_factories, g_object_unref);
 
   g_slice_free (StyleData, data);
 }
@@ -806,11 +805,9 @@ gtk_style_context_finalize (GObject *object)
 
   g_hash_table_destroy (priv->style_data);
 
-  g_list_foreach (priv->providers, (GFunc) style_provider_data_free, NULL);
-  g_list_free (priv->providers);
+  g_list_free_full (priv->providers, (GDestroyNotify) style_provider_data_free);
 
-  g_slist_foreach (priv->info_stack, (GFunc) style_info_free, NULL);
-  g_slist_free (priv->info_stack);
+  g_slist_free_full (priv->info_stack, (GDestroyNotify) style_info_free);
 
   g_slist_free (priv->animation_regions);
 
diff --git a/gtk/gtktextbufferrichtext.c b/gtk/gtktextbufferrichtext.c
index e4e6836..071f5e1 100644
--- a/gtk/gtktextbufferrichtext.c
+++ b/gtk/gtktextbufferrichtext.c
@@ -797,8 +797,7 @@ free_format (GtkRichTextFormat *format)
 static void
 free_format_list (GList *formats)
 {
-  g_list_foreach (formats, (GFunc) free_format, NULL);
-  g_list_free (formats);
+  g_list_free_full (formats, (GDestroyNotify) free_format);
 }
 
 static GQuark
diff --git a/gtk/gtktextbufferserialize.c b/gtk/gtktextbufferserialize.c
index c750a80..98ef116 100644
--- a/gtk/gtktextbufferserialize.c
+++ b/gtk/gtktextbufferserialize.c
@@ -1784,8 +1784,7 @@ read_headers (const gchar *start,
   return g_list_reverse (headers);
 
  error:
-  g_list_foreach (headers, (GFunc) g_free, NULL);
-  g_list_free (headers);
+  g_list_free_full (headers, g_free);
 
   g_set_error_literal (error,
                        G_MARKUP_ERROR,
@@ -1879,8 +1878,7 @@ _gtk_text_buffer_deserialize_rich_text (GtkTextBuffer *register_buffer,
 			     create_tags, error, headers->next);
 
  out:
-  g_list_foreach (headers, (GFunc)g_free, NULL);
-  g_list_free (headers);
+  g_list_free_full (headers, g_free);
 
   return retval;
 }
diff --git a/gtk/gtktreeview.c b/gtk/gtktreeview.c
index b01273a..394f0c6 100644
--- a/gtk/gtktreeview.c
+++ b/gtk/gtktreeview.c
@@ -10148,8 +10148,7 @@ gtk_tree_view_focus_to_cursor (GtkTreeView *tree_view)
       if (selected_rows)
 	{
           cursor_path = gtk_tree_path_copy((const 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);
         }
       else
 	{
diff --git a/gtk/gtkuimanager.c b/gtk/gtkuimanager.c
index b426865..82c638c 100644
--- a/gtk/gtkuimanager.c
+++ b/gtk/gtkuimanager.c
@@ -680,9 +680,7 @@ gtk_ui_manager_finalize (GObject *object)
   g_node_destroy (manager->private_data->root_node);
   manager->private_data->root_node = NULL;
   
-  g_list_foreach (manager->private_data->action_groups,
-                  (GFunc) g_object_unref, NULL);
-  g_list_free (manager->private_data->action_groups);
+  g_list_free_full (manager->private_data->action_groups, g_object_unref);
   manager->private_data->action_groups = NULL;
 
   g_object_unref (manager->private_data->accel_group);
@@ -1392,8 +1390,7 @@ free_node (GNode *node)
 {
   Node *info = NODE_INFO (node);
   
-  g_list_foreach (info->uifiles, (GFunc) node_ui_reference_free, NULL);
-  g_list_free (info->uifiles);
+  g_list_free_full (info->uifiles, node_ui_reference_free);
 
   if (info->action)
     g_object_unref (info->action);
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index fe790f9..a830741 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -12030,8 +12030,7 @@ gtk_widget_buildable_parser_finished (GtkBuildable *buildable,
 	}
       g_object_unref (relation_set);
 
-      g_slist_foreach (atk_relations, (GFunc)free_relation, NULL);
-      g_slist_free (atk_relations);
+      g_slist_free_full (atk_relations, (GDestroyNotify) free_relation);
       g_object_set_qdata (G_OBJECT (buildable), quark_builder_atk_relations,
 			  NULL);
     }
@@ -12438,8 +12437,7 @@ gtk_widget_buildable_custom_finished (GtkBuildable *buildable,
           else
             g_warning ("accessibility action on a widget that does not implement AtkAction");
 
-	  g_slist_foreach (a11y_data->actions, (GFunc)free_action, NULL);
-	  g_slist_free (a11y_data->actions);
+	  g_slist_free_full (a11y_data->actions, (GDestroyNotify) free_action);
 	}
 
       if (a11y_data->relations)
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index f61e4a2..62e75ee 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -3482,8 +3482,7 @@ gtk_window_realize_icon (GtkWindow *window)
     {
       GtkIconTheme *icon_theme;
 
-      g_list_foreach (icon_list, (GFunc) g_object_unref, NULL);
-      g_list_free (icon_list);
+      g_list_free_full (icon_list, g_object_unref);
  
       icon_theme = gtk_icon_theme_get_for_screen (gtk_widget_get_screen (GTK_WIDGET (window)));
       g_signal_connect (icon_theme, "changed",
@@ -3564,10 +3563,7 @@ gtk_window_set_icon_list (GtkWindow  *window,
   g_list_foreach (list,
                   (GFunc) g_object_ref, NULL);
 
-  g_list_foreach (info->icon_list,
-                  (GFunc) g_object_unref, NULL);
-
-  g_list_free (info->icon_list);
+  g_list_free_full (info->icon_list, g_object_unref);
 
   info->icon_list = g_list_copy (list);
 
@@ -3695,8 +3691,7 @@ gtk_window_set_icon_name (GtkWindow   *window,
   info->icon_name = g_strdup (name);
   g_free (tmp);
 
-  g_list_foreach (info->icon_list, (GFunc) g_object_unref, NULL);
-  g_list_free (info->icon_list);
+  g_list_free_full (info->icon_list, g_object_unref);
   info->icon_list = NULL;
   
   update_themed_icon (NULL, window);
@@ -3839,10 +3834,7 @@ gtk_window_set_default_icon_list (GList *list)
   g_list_foreach (list,
                   (GFunc) g_object_ref, NULL);
 
-  g_list_foreach (default_icon_list,
-                  (GFunc) g_object_unref, NULL);
-
-  g_list_free (default_icon_list);
+  g_list_free_full (default_icon_list, g_object_unref);
 
   default_icon_list = g_list_copy (list);
   
@@ -3911,10 +3903,7 @@ gtk_window_set_default_icon_name (const gchar *name)
   g_free (default_icon_name);
   default_icon_name = g_strdup (name);
 
-  g_list_foreach (default_icon_list,
-                  (GFunc) g_object_unref, NULL);
-
-  g_list_free (default_icon_list);
+  g_list_free_full (default_icon_list, g_object_unref);
   default_icon_list = NULL;
   
   /* Update all toplevels */
diff --git a/gtk/updateiconcache.c b/gtk/updateiconcache.c
index 6988215..95db497 100644
--- a/gtk/updateiconcache.c
+++ b/gtk/updateiconcache.c
@@ -1525,8 +1525,7 @@ opentmp:
     }
   cache = NULL;
 
-  g_list_foreach (directories, (GFunc)g_free, NULL);
-  g_list_free (directories);
+  g_list_free_full (directories, g_free);
 
   if (!validate_file (tmp_cache_path))
     {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]