[gupnp] Use g_list_free_full



commit 8abfa8082997bf59cd20aba2bd86de0eb3f88279
Author: Jens Georg <mail jensge org>
Date:   Sat May 24 18:47:40 2014 +0200

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

 libgupnp/gupnp-context.c       |   18 +++---------------
 libgupnp/gupnp-device-info.c   |    5 +----
 libgupnp/gupnp-service-proxy.c |   17 ++++-------------
 libgupnp/gupnp-service.c       |   13 ++-----------
 4 files changed, 10 insertions(+), 43 deletions(-)
---
diff --git a/libgupnp/gupnp-context.c b/libgupnp/gupnp-context.c
index 28baa66..e2865e6 100644
--- a/libgupnp/gupnp-context.c
+++ b/libgupnp/gupnp-context.c
@@ -1129,10 +1129,7 @@ host_path_handler (G_GNUC_UNUSED SoupServer        *server,
         g_free (path_to_open);
         g_free (local_path);
 
-        while (orig_locales) {
-                g_free (orig_locales->data);
-                orig_locales = g_list_delete_link (orig_locales, orig_locales);
-        }
+        g_list_free_full (orig_locales, g_free);
 }
 
 static UserAgent *
@@ -1181,17 +1178,8 @@ host_path_data_free (HostPathData *path_data)
         g_free (path_data->server_path);
         g_free (path_data->default_language);
 
-        while (path_data->user_agents) {
-                UserAgent *agent;
-
-                agent = path_data->user_agents->data;
-
-                user_agent_free (agent);
-
-                path_data->user_agents = g_list_delete_link (
-                                path_data->user_agents,
-                                path_data->user_agents);
-        }
+        g_list_free_full (path_data->user_agents,
+                          (GDestroyNotify) user_agent_free);
 
         g_slice_free (HostPathData, path_data);
 }
diff --git a/libgupnp/gupnp-device-info.c b/libgupnp/gupnp-device-info.c
index 1bb6efe..0e21ee4 100644
--- a/libgupnp/gupnp-device-info.c
+++ b/libgupnp/gupnp-device-info.c
@@ -864,10 +864,7 @@ gupnp_device_info_get_icon_url (GUPnPDeviceInfo *info,
         }
 
         /* Cleanup */
-        while (icons) {
-                icon_free (icons->data);
-                icons = g_list_delete_link (icons, icons);
-        }
+        g_list_free_full (icons, (GDestroyNotify) icon_free);
 
         return ret;
 }
diff --git a/libgupnp/gupnp-service-proxy.c b/libgupnp/gupnp-service-proxy.c
index c0bbcfe..ec1253b 100644
--- a/libgupnp/gupnp-service-proxy.c
+++ b/libgupnp/gupnp-service-proxy.c
@@ -294,12 +294,8 @@ gupnp_service_proxy_dispose (GObject *object)
                 proxy->priv->notify_idle_src = NULL;
         }
 
-        while (proxy->priv->pending_notifies) {
-                emit_notify_data_free (proxy->priv->pending_notifies->data);
-                proxy->priv->pending_notifies =
-                        g_list_delete_link (proxy->priv->pending_notifies,
-                                            proxy->priv->pending_notifies);
-        }
+        g_list_free_full (proxy->priv->pending_notifies,
+                          (GDestroyNotify) emit_notify_data_free);
 
         /* Call super */
         object_class = G_OBJECT_CLASS (gupnp_service_proxy_parent_class);
@@ -1872,13 +1868,8 @@ emit_notifications (gpointer user_data)
         }
 
         /* Cleanup */
-        while (proxy->priv->pending_notifies != NULL) {
-                emit_notify_data_free (proxy->priv->pending_notifies->data);
-
-                proxy->priv->pending_notifies =
-                        g_list_delete_link (proxy->priv->pending_notifies,
-                                            proxy->priv->pending_notifies);
-        }
+        g_list_free_full (proxy->priv->pending_notifies,
+                          (GDestroyNotify) emit_notify_data_free);
 
         proxy->priv->notify_idle_src = NULL;
 
diff --git a/libgupnp/gupnp-service.c b/libgupnp/gupnp-service.c
index 486cde4..8e203f6 100644
--- a/libgupnp/gupnp-service.c
+++ b/libgupnp/gupnp-service.c
@@ -168,11 +168,7 @@ subscription_data_free (SubscriptionData *data)
         }
        
         /* Further cleanup */
-        while (data->callbacks) {
-                g_free (data->callbacks->data);
-                data->callbacks = g_list_delete_link (data->callbacks,
-                                                      data->callbacks);
-        }
+        g_list_free_full (data->callbacks, g_free);
 
         g_free (data->sid);
 
@@ -1624,12 +1620,7 @@ gupnp_service_finalize (GObject *object)
         g_hash_table_destroy (service->priv->subscriptions);
 
         /* Free state variable list */
-        while (service->priv->state_variables) {
-                g_free (service->priv->state_variables->data);
-                service->priv->state_variables =
-                        g_list_delete_link (service->priv->state_variables,
-                                            service->priv->state_variables);
-        }
+        g_list_free_full (service->priv->state_variables, g_free);
 
         /* Free notify queue */
         while ((data = g_queue_pop_head (service->priv->notify_queue)))


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