[gssdp] Use g_list_free_full ()



commit 3a257bafe5f5eb4b488ee30213d47221b81c60fa
Author: Jens Georg <mail jensge org>
Date:   Sat Mar 15 09:08:39 2014 +0100

    Use g_list_free_full ()
    
    Signed-off-by: Jens Georg <mail jensge org>

 libgssdp/gssdp-resource-browser.c |   28 ++++++----------------------
 libgssdp/gssdp-resource-group.c   |    8 ++------
 2 files changed, 8 insertions(+), 28 deletions(-)
---
diff --git a/libgssdp/gssdp-resource-browser.c b/libgssdp/gssdp-resource-browser.c
index bd52f80..0aed07d 100644
--- a/libgssdp/gssdp-resource-browser.c
+++ b/libgssdp/gssdp-resource-browser.c
@@ -106,7 +106,7 @@ message_received_cb              (GSSDPClient          *client,
                                   SoupMessageHeaders   *headers,
                                   gpointer              user_data);
 static void
-resource_free                    (gpointer              data);
+resource_free                    (Resource             *data);
 static void
 clear_cache                      (GSSDPResourceBrowser *resource_browser);
 static void
@@ -137,7 +137,7 @@ gssdp_resource_browser_init (GSSDPResourceBrowser *resource_browser)
                 g_hash_table_new_full (g_str_hash,
                                        g_str_equal,
                                        g_free,
-                                       resource_free);
+                                       (GFreeFunc) resource_free);
 }
 
 static void
@@ -872,13 +872,8 @@ resource_available (GSSDPResourceBrowser *resource_browser,
                                locations);
         }
         /* Cleanup */
-        if (destroyLocations) {
-                while (locations) {
-                        g_free (locations->data);
-
-                        locations = g_list_delete_link (locations, locations);
-                }
-        }
+        if (destroyLocations)
+                g_list_free_full (locations, g_free);
 }
 
 static void
@@ -1041,22 +1036,11 @@ message_received_cb (G_GNUC_UNUSED GSSDPClient *client,
  * Free a Resource structure and its contained data
  */
 static void
-resource_free (gpointer data)
+resource_free (Resource *resource)
 {
-        Resource *resource;
-        resource = data;
-        GList    *locations;
-        locations = resource->locations;
-
         g_free (resource->usn);
-
         g_source_destroy (resource->timeout_src);
-
-        while (locations) {
-                g_free (locations->data);
-                locations = g_list_delete_link (locations, locations);
-        }
-
+        g_list_free_full (resource->locations, g_free);
         g_slice_free (Resource, resource);
 }
 
diff --git a/libgssdp/gssdp-resource-group.c b/libgssdp/gssdp-resource-group.c
index dac4c78..9a7c1c6 100644
--- a/libgssdp/gssdp-resource-group.c
+++ b/libgssdp/gssdp-resource-group.c
@@ -232,12 +232,8 @@ gssdp_resource_group_dispose (GObject *object)
         resource_group = GSSDP_RESOURCE_GROUP (object);
         priv = resource_group->priv;
 
-        while (priv->resources) {
-                resource_free (priv->resources->data);
-                priv->resources =
-                        g_list_delete_link (priv->resources,
-                                            priv->resources);
-        }
+        g_list_free_full (priv->resources, (GFreeFunc) resource_free);
+        priv->resources = NULL;
 
         if (priv->message_queue) {
                 /* send messages without usual delay */


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