summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Georg <mail@jensge.org>2014-03-15 09:08:39 +0100
committerJens Georg <mail@jensge.org>2014-03-15 10:01:23 +0100
commit3a257bafe5f5eb4b488ee30213d47221b81c60fa (patch)
tree3fbda3c8316ead5f3623383306a6dcaeda1bacde
parent9f7d8628cdafe0eb2797ece58af9fd3e91b6511d (diff)
downloadgssdp-3a257bafe5f5eb4b488ee30213d47221b81c60fa.tar.gz
Use g_list_free_full ()
Signed-off-by: Jens Georg <mail@jensge.org>
-rw-r--r--libgssdp/gssdp-resource-browser.c28
-rw-r--r--libgssdp/gssdp-resource-group.c8
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 */