[vinagre] Use g_slist_free_full() where possible



commit 504099c362bee382547a9bdee7d66b97b3b75f76
Author: David King <amigadave amigadave com>
Date:   Fri Jul 1 23:48:18 2011 +0200

    Use g_slist_free_full() where possible
    
    g_slist_free_full() has existed since GLib 2.28, and can be used instead
    of freeing a dynamically-allocated GSList with g_slist_foreach(),
    followed by calling g_slist_free(). The GLib configure requirement was
    bumped to 2.28.

 configure.ac                          |    2 +-
 vinagre/vinagre-bookmarks-entry.c     |    6 ++----
 vinagre/vinagre-bookmarks-migration.c |    3 +--
 vinagre/vinagre-bookmarks.c           |    3 +--
 vinagre/vinagre-commands.c            |    9 +--------
 vinagre/vinagre-mdns.c                |    3 +--
 vinagre/vinagre-tab.c                 |    5 ++---
 7 files changed, 9 insertions(+), 22 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 7bb3039..b53a067 100644
--- a/configure.ac
+++ b/configure.ac
@@ -38,7 +38,7 @@ AC_DEFINE_UNQUOTED([VINAGRE_ABI_VERSION], ["$VINAGRE_ABI_VERSION"], [Vinagre ABI
 AC_SUBST([PLUGIN_LIBTOOL_FLAGS], ["-avoid-version"])
 AC_SUBST([VINAGRE_PLUGINS_LIBS_DIR], ["$libdir/vinagre-$VINAGRE_ABI_VERSION/plugins"])
 
-GLIB_DEPS="glib-2.0 >= 2.25.11 $gio_os >= 2.25.11"
+GLIB_DEPS="glib-2.0 >= 2.28.0 $gio_os >= 2.28.0"
 GTHREAD_DEPS="gthread-2.0 >= 2.0.0"
 GTK_DEPS="gtk+-3.0 >= 3.0.3"
 GTK_VNC_DEPS="gtk-vnc-2.0 >= 0.4.3"
diff --git a/vinagre/vinagre-bookmarks-entry.c b/vinagre/vinagre-bookmarks-entry.c
index 383a279..79604cd 100644
--- a/vinagre/vinagre-bookmarks-entry.c
+++ b/vinagre/vinagre-bookmarks-entry.c
@@ -72,8 +72,7 @@ vinagre_bookmarks_entry_dispose (GObject *object)
       case VINAGRE_BOOKMARKS_ENTRY_NODE_FOLDER:
 	if (entry->priv->children)
 	  {
-	    g_slist_foreach (entry->priv->children, (GFunc) g_object_unref, NULL);
-	    g_slist_free (entry->priv->children);
+	    g_slist_free_full (entry->priv->children, g_object_unref);
 	    entry->priv->children = NULL;
 	  }
 	break;
@@ -140,8 +139,7 @@ vinagre_bookmarks_entry_set_node (VinagreBookmarksEntry *entry, VinagreBookmarks
       case VINAGRE_BOOKMARKS_ENTRY_NODE_CONN:
 	g_free (entry->priv->name);
 	entry->priv->name = NULL;
-	g_slist_foreach (entry->priv->children, (GFunc) g_object_unref, NULL);
-	g_slist_free (entry->priv->children);
+	g_slist_free_full (entry->priv->children, g_object_unref);
 	entry->priv->children = NULL;
 	break;
 
diff --git a/vinagre/vinagre-bookmarks-migration.c b/vinagre/vinagre-bookmarks-migration.c
index 68ee504..dd4304c 100644
--- a/vinagre/vinagre-bookmarks-migration.c
+++ b/vinagre/vinagre-bookmarks-migration.c
@@ -260,8 +260,7 @@ vinagre_bookmarks_migration_migrate (const gchar *filename)
   else
     g_warning (_("Migration cancelled"));
 
-  g_slist_foreach (entries, (GFunc) g_object_unref, NULL);
-  g_slist_free (entries);
+  g_slist_free_full (entries, g_object_unref);
   g_key_file_free (kf);
   g_free (old);
 }
diff --git a/vinagre/vinagre-bookmarks.c b/vinagre/vinagre-bookmarks.c
index 2087145..9ee96ae 100644
--- a/vinagre/vinagre-bookmarks.c
+++ b/vinagre/vinagre-bookmarks.c
@@ -112,8 +112,7 @@ vinagre_bookmarks_init (VinagreBookmarks *book)
 static void
 vinagre_bookmarks_clear_entries (VinagreBookmarks *book)
 {
-  g_slist_foreach (book->priv->entries, (GFunc) g_object_unref, NULL);
-  g_slist_free (book->priv->entries);
+  g_slist_free_full (book->priv->entries, g_object_unref);
 
   book->priv->entries = NULL;
 }
diff --git a/vinagre/vinagre-commands.c b/vinagre/vinagre-commands.c
index e435c98..13c2254 100644
--- a/vinagre/vinagre-commands.c
+++ b/vinagre/vinagre-commands.c
@@ -91,12 +91,6 @@ vinagre_cmd_remote_connect (GtkAction     *action,
   g_object_unref (conn);
 }
 
-static void
-vinagre_cmd_free_string_list (gpointer str, gpointer user_data)
-{
-  g_free (str);
-}
-
 void
 vinagre_cmd_remote_open (GtkAction     *action,
 			  VinagreWindow *window)
@@ -180,8 +174,7 @@ vinagre_cmd_remote_open (GtkAction     *action,
 						 g_slist_length (errors)),
 				      errors,
 				      GTK_WINDOW (window));
-      g_slist_foreach (errors, vinagre_cmd_free_string_list, NULL);
-      g_slist_free (errors);
+      g_slist_free_full (errors, g_free);
     }
 
 finalize:
diff --git a/vinagre/vinagre-mdns.c b/vinagre/vinagre-mdns.c
index d651d62..bfde27e 100644
--- a/vinagre/vinagre-mdns.c
+++ b/vinagre/vinagre-mdns.c
@@ -361,8 +361,7 @@ vinagre_mdns_dispose (GObject *object)
 
   if (mdns->priv->entries)
     {
-      g_slist_foreach (mdns->priv->entries, (GFunc) g_object_unref, NULL);
-      g_slist_free (mdns->priv->entries);
+      g_slist_free_full (mdns->priv->entries, g_object_unref);
       mdns->priv->entries = NULL;
     }
 
diff --git a/vinagre/vinagre-tab.c b/vinagre/vinagre-tab.c
index 649aab2..5b15e65 100644
--- a/vinagre/vinagre-tab.c
+++ b/vinagre/vinagre-tab.c
@@ -996,7 +996,7 @@ vinagre_tab_get_initialized_actions (VinagreTab *tab)
 }
 
 static void
-free_actions (gpointer data, gpointer user_data)
+_free_action (gpointer data)
 {
   VinagreTabUiAction *action = (VinagreTabUiAction *)data;
 
@@ -1008,8 +1008,7 @@ free_actions (gpointer data, gpointer user_data)
 void
 vinagre_tab_free_actions (GSList *actions)
 {
-  g_slist_foreach (actions, (GFunc) free_actions, NULL);
-  g_slist_free (actions);
+  g_slist_free_full (actions, _free_action);
 }
 
 const gchar *



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