[libsoup] Use g_slist_free_full()
- From: Dan Winship <danw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libsoup] Use g_slist_free_full()
- Date: Fri, 13 Jul 2012 18:20:24 +0000 (UTC)
commit b3b7df0c0beea646479be468b888becce5336c87
Author: Dan Winship <danw gnome org>
Date: Mon Jul 2 09:49:48 2012 -0400
Use g_slist_free_full()
libsoup/soup-auth.c | 6 +-----
libsoup/soup-content-decoder.c | 5 +----
libsoup/soup-cookie.c | 6 +-----
libsoup/soup-headers.c | 6 +-----
libsoup/soup-message-body.c | 5 +----
libsoup/soup-message.c | 10 ++--------
libsoup/soup-server.c | 5 +----
libsoup/soup-session.c | 8 ++------
8 files changed, 10 insertions(+), 41 deletions(-)
---
diff --git a/libsoup/soup-auth.c b/libsoup/soup-auth.c
index e72e5c3..5b77aa7 100644
--- a/libsoup/soup-auth.c
+++ b/libsoup/soup-auth.c
@@ -540,11 +540,7 @@ soup_auth_get_protection_space (SoupAuth *auth, SoupURI *source_uri)
void
soup_auth_free_protection_space (SoupAuth *auth, GSList *space)
{
- GSList *s;
-
- for (s = space; s; s = s->next)
- g_free (s->data);
- g_slist_free (space);
+ g_slist_free_full (space, g_free);
}
/**
diff --git a/libsoup/soup-content-decoder.c b/libsoup/soup-content-decoder.c
index e686896..e25caff 100644
--- a/libsoup/soup-content-decoder.c
+++ b/libsoup/soup-content-decoder.c
@@ -167,10 +167,7 @@ soup_content_decoder_got_headers_cb (SoupMessage *msg, SoupContentDecoder *decod
/* msgpriv->decoders should be empty at this point anyway, but
* clean it up if it's not.
*/
- while (msgpriv->decoders) {
- g_object_unref (msgpriv->decoders->data);
- msgpriv->decoders = g_slist_delete_link (msgpriv->decoders, msgpriv->decoders);
- }
+ g_slist_free_full (msgpriv->decoders, g_object_unref);
for (e = encodings; e; e = e->next) {
converter_creator = g_hash_table_lookup (decoder->priv->decoders, e->data);
diff --git a/libsoup/soup-cookie.c b/libsoup/soup-cookie.c
index 6f05f35..fbf3ac8 100755
--- a/libsoup/soup-cookie.c
+++ b/libsoup/soup-cookie.c
@@ -1001,11 +1001,7 @@ soup_cookies_to_request (GSList *cookies, SoupMessage *msg)
void
soup_cookies_free (GSList *cookies)
{
- GSList *c;
-
- for (c = cookies; c; c = c->next)
- soup_cookie_free (c->data);
- g_slist_free (cookies);
+ g_slist_free_full (cookies, (GDestroyNotify)soup_cookie_free);
}
/**
diff --git a/libsoup/soup-headers.c b/libsoup/soup-headers.c
index 965f9da..5b85c71 100644
--- a/libsoup/soup-headers.c
+++ b/libsoup/soup-headers.c
@@ -601,11 +601,7 @@ soup_header_parse_quality_list (const char *header, GSList **unacceptable)
void
soup_header_free_list (GSList *list)
{
- GSList *l;
-
- for (l = list; l; l = l->next)
- g_free (l->data);
- g_slist_free (list);
+ g_slist_free_full (list, g_free);
}
/**
diff --git a/libsoup/soup-message-body.c b/libsoup/soup-message-body.c
index 9a6ad75..cfcc0bc 100644
--- a/libsoup/soup-message-body.c
+++ b/libsoup/soup-message-body.c
@@ -544,11 +544,8 @@ void
soup_message_body_truncate (SoupMessageBody *body)
{
SoupMessageBodyPrivate *priv = (SoupMessageBodyPrivate *)body;
- GSList *iter;
- for (iter = priv->chunks; iter; iter = iter->next)
- soup_buffer_free (iter->data);
- g_slist_free (priv->chunks);
+ g_slist_free_full (priv->chunks, (GDestroyNotify)soup_buffer_free);
priv->chunks = priv->last = NULL;
priv->base_offset = 0;
diff --git a/libsoup/soup-message.c b/libsoup/soup-message.c
index 727383e..3da4e69 100644
--- a/libsoup/soup-message.c
+++ b/libsoup/soup-message.c
@@ -179,10 +179,7 @@ finalize (GObject *object)
g_slist_free (priv->disabled_features);
- while (priv->decoders) {
- g_object_unref (priv->decoders->data);
- priv->decoders = g_slist_delete_link (priv->decoders, priv->decoders);
- }
+ g_slist_free_full (priv->decoders, g_object_unref);
if (priv->tls_certificate)
g_object_unref (priv->tls_certificate);
@@ -1434,10 +1431,7 @@ soup_message_cleanup_response (SoupMessage *req)
SOUP_ENCODING_CONTENT_LENGTH);
}
- while (priv->decoders) {
- g_object_unref (priv->decoders->data);
- priv->decoders = g_slist_delete_link (priv->decoders, priv->decoders);
- }
+ g_slist_free_full (priv->decoders, g_object_unref);
priv->msg_flags &= ~SOUP_MESSAGE_CONTENT_DECODED;
req->status_code = SOUP_STATUS_NONE;
diff --git a/libsoup/soup-server.c b/libsoup/soup-server.c
index 26bfcdf..d04b5d1 100644
--- a/libsoup/soup-server.c
+++ b/libsoup/soup-server.c
@@ -165,7 +165,6 @@ finalize (GObject *object)
{
SoupServer *server = SOUP_SERVER (object);
SoupServerPrivate *priv = SOUP_SERVER_GET_PRIVATE (server);
- GSList *iter;
if (priv->iface)
g_object_unref (priv->iface);
@@ -208,9 +207,7 @@ finalize (GObject *object)
free_handler (priv->default_handler);
soup_path_map_free (priv->handlers);
- for (iter = priv->auth_domains; iter; iter = iter->next)
- g_object_unref (iter->data);
- g_slist_free (priv->auth_domains);
+ g_slist_free_full (priv->auth_domains, g_object_unref);
if (priv->loop)
g_main_loop_unref (priv->loop);
diff --git a/libsoup/soup-session.c b/libsoup/soup-session.c
index 97a379a..0fb9b03 100644
--- a/libsoup/soup-session.c
+++ b/libsoup/soup-session.c
@@ -1542,12 +1542,8 @@ get_host_for_message (SoupSession *session, SoupMessage *msg)
static void
free_host (SoupSessionHost *host)
{
- while (host->connections) {
- SoupConnection *conn = host->connections->data;
-
- host->connections = g_slist_remove (host->connections, conn);
- soup_connection_disconnect (conn);
- }
+ g_slist_free_full (host->connections,
+ (GDestroyNotify) soup_connection_disconnect);
if (host->keep_alive_src) {
g_source_destroy (host->keep_alive_src);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]