summaryrefslogtreecommitdiff
path: root/libsoup
diff options
context:
space:
mode:
authorDan Winship <danw@gnome.org>2012-07-02 10:49:53 -0400
committerDan Winship <danw@gnome.org>2012-07-13 14:18:36 -0400
commit06f64f9db08ec4140b66c118f3fcf5edd6bdeec3 (patch)
tree040b1239f4680fe5ddb50396edc61d1e6072852d /libsoup
parentdba99c7857d42189201f30ddcf77ed9962f2df31 (diff)
downloadlibsoup-06f64f9db08ec4140b66c118f3fcf5edd6bdeec3.tar.gz
Use g_clear_object(), g_clear_pointer()
Diffstat (limited to 'libsoup')
-rw-r--r--libsoup/soup-address.c9
-rw-r--r--libsoup/soup-auth-digest.c12
-rw-r--r--libsoup/soup-auth-manager-ntlm.c3
-rw-r--r--libsoup/soup-auth-manager.c9
-rw-r--r--libsoup/soup-cache.c24
-rw-r--r--libsoup/soup-client-input-stream.c3
-rw-r--r--libsoup/soup-connection.c16
-rw-r--r--libsoup/soup-content-sniffer-stream.c18
-rw-r--r--libsoup/soup-converter-wrapper.c3
-rwxr-xr-xlibsoup/soup-cookie.c4
-rw-r--r--libsoup/soup-filter-input-stream.c3
-rw-r--r--libsoup/soup-io-stream.c3
-rw-r--r--libsoup/soup-message-headers.c3
-rw-r--r--libsoup/soup-message.c18
-rw-r--r--libsoup/soup-proxy-resolver-default.c3
-rw-r--r--libsoup/soup-proxy-resolver-static.c3
-rw-r--r--libsoup/soup-request-file.c3
-rw-r--r--libsoup/soup-request.c6
-rw-r--r--libsoup/soup-server.c18
-rw-r--r--libsoup/soup-session.c6
-rw-r--r--libsoup/soup-socket.c9
21 files changed, 54 insertions, 122 deletions
diff --git a/libsoup/soup-address.c b/libsoup/soup-address.c
index 5f5040f1..25c1b250 100644
--- a/libsoup/soup-address.c
+++ b/libsoup/soup-address.c
@@ -128,12 +128,9 @@ finalize (GObject *object)
SoupAddress *addr = SOUP_ADDRESS (object);
SoupAddressPrivate *priv = SOUP_ADDRESS_GET_PRIVATE (addr);
- if (priv->sockaddr)
- g_free (priv->sockaddr);
- if (priv->name)
- g_free (priv->name);
- if (priv->physical)
- g_free (priv->physical);
+ g_free (priv->sockaddr);
+ g_free (priv->name);
+ g_free (priv->physical);
g_mutex_clear (&priv->lock);
diff --git a/libsoup/soup-auth-digest.c b/libsoup/soup-auth-digest.c
index 90718c6c..487e4b56 100644
--- a/libsoup/soup-auth-digest.c
+++ b/libsoup/soup-auth-digest.c
@@ -60,14 +60,10 @@ finalize (GObject *object)
{
SoupAuthDigestPrivate *priv = SOUP_AUTH_DIGEST_GET_PRIVATE (object);
- if (priv->user)
- g_free (priv->user);
- if (priv->nonce)
- g_free (priv->nonce);
- if (priv->domain)
- g_free (priv->domain);
- if (priv->cnonce)
- g_free (priv->cnonce);
+ g_free (priv->user);
+ g_free (priv->nonce);
+ g_free (priv->domain);
+ g_free (priv->cnonce);
memset (priv->hex_urp, 0, sizeof (priv->hex_urp));
memset (priv->hex_a1, 0, sizeof (priv->hex_a1));
diff --git a/libsoup/soup-auth-manager-ntlm.c b/libsoup/soup-auth-manager-ntlm.c
index 1e6ebe51..04771b4a 100644
--- a/libsoup/soup-auth-manager-ntlm.c
+++ b/libsoup/soup-auth-manager-ntlm.c
@@ -121,8 +121,7 @@ free_ntlm_connection (SoupNTLMConnection *conn)
g_free (conn->response_header);
g_free (conn->nonce);
g_free (conn->domain);
- if (conn->auth)
- g_object_unref (conn->auth);
+ g_clear_object (&conn->auth);
#ifdef USE_NTLM_AUTH
g_free (conn->challenge_header);
sso_ntlm_close (conn);
diff --git a/libsoup/soup-auth-manager.c b/libsoup/soup-auth-manager.c
index 6d845be9..ba1d7c5e 100644
--- a/libsoup/soup-auth-manager.c
+++ b/libsoup/soup-auth-manager.c
@@ -86,8 +86,7 @@ finalize (GObject *object)
g_hash_table_destroy (priv->auth_hosts);
- if (priv->proxy_auth)
- g_object_unref (priv->proxy_auth);
+ g_clear_object (&priv->proxy_auth);
G_OBJECT_CLASS (soup_auth_manager_parent_class)->finalize (object);
}
@@ -388,10 +387,8 @@ get_auth_host_for_message (SoupAuthManagerPrivate *priv, SoupMessage *msg)
static void
soup_auth_host_free (SoupAuthHost *host)
{
- if (host->auth_realms)
- soup_path_map_free (host->auth_realms);
- if (host->auths)
- g_hash_table_destroy (host->auths);
+ g_clear_pointer (&host->auth_realms, soup_path_map_free);
+ g_clear_pointer (&host->auths, g_hash_table_destroy);
soup_uri_free (host->uri);
g_slice_free (SoupAuthHost, host);
diff --git a/libsoup/soup-cache.c b/libsoup/soup-cache.c
index 9dae00f5..fc440539 100644
--- a/libsoup/soup-cache.c
+++ b/libsoup/soup-cache.c
@@ -274,25 +274,10 @@ soup_cache_entry_free (SoupCacheEntry *entry, GFile *file)
}
g_free (entry->uri);
- entry->uri = NULL;
-
- if (entry->current_writing_buffer) {
- soup_buffer_free (entry->current_writing_buffer);
- entry->current_writing_buffer = NULL;
- }
-
- if (entry->headers) {
- soup_message_headers_free (entry->headers);
- entry->headers = NULL;
- }
- if (entry->error) {
- g_error_free (entry->error);
- entry->error = NULL;
- }
- if (entry->cancellable) {
- g_object_unref (entry->cancellable);
- entry->cancellable = NULL;
- }
+ g_clear_pointer (&entry->current_writing_buffer, soup_buffer_free);
+ g_clear_pointer (&entry->headers, soup_message_headers_free);
+ g_clear_error (&entry->error);
+ g_clear_object (&entry->cancellable);
g_slice_free (SoupCacheEntry, entry);
}
@@ -1162,7 +1147,6 @@ soup_cache_finalize (GObject *object)
g_free (priv->cache_dir);
g_list_free (priv->lru_start);
- priv->lru_start = NULL;
G_OBJECT_CLASS (soup_cache_parent_class)->finalize (object);
}
diff --git a/libsoup/soup-client-input-stream.c b/libsoup/soup-client-input-stream.c
index 99b30939..155680fc 100644
--- a/libsoup/soup-client-input-stream.c
+++ b/libsoup/soup-client-input-stream.c
@@ -162,8 +162,7 @@ typedef struct {
static void
close_async_data_free (CloseAsyncData *cad)
{
- if (cad->cancellable)
- g_object_unref (cad->cancellable);
+ g_clear_object (&cad->cancellable);
g_object_unref (cad->result);
g_slice_free (CloseAsyncData, cad);
}
diff --git a/libsoup/soup-connection.c b/libsoup/soup-connection.c
index 9b079fa4..11d54ff2 100644
--- a/libsoup/soup-connection.c
+++ b/libsoup/soup-connection.c
@@ -103,17 +103,11 @@ finalize (GObject *object)
{
SoupConnectionPrivate *priv = SOUP_CONNECTION_GET_PRIVATE (object);
- if (priv->remote_uri)
- soup_uri_free (priv->remote_uri);
- if (priv->proxy_uri)
- soup_uri_free (priv->proxy_uri);
- if (priv->tlsdb)
- g_object_unref (priv->tlsdb);
- if (priv->proxy_resolver)
- g_object_unref (priv->proxy_resolver);
-
- if (priv->async_context)
- g_main_context_unref (priv->async_context);
+ g_clear_pointer (&priv->remote_uri, soup_uri_free);
+ g_clear_pointer (&priv->proxy_uri, soup_uri_free);
+ g_clear_object (&priv->tlsdb);
+ g_clear_object (&priv->proxy_resolver);
+ g_clear_pointer (&priv->async_context, g_main_context_unref);
G_OBJECT_CLASS (soup_connection_parent_class)->finalize (object);
}
diff --git a/libsoup/soup-content-sniffer-stream.c b/libsoup/soup-content-sniffer-stream.c
index a391c85f..14a21a32 100644
--- a/libsoup/soup-content-sniffer-stream.c
+++ b/libsoup/soup-content-sniffer-stream.c
@@ -47,18 +47,12 @@ soup_content_sniffer_stream_finalize (GObject *object)
{
SoupContentSnifferStream *sniffer = SOUP_CONTENT_SNIFFER_STREAM (object);
- if (sniffer->priv->sniffer)
- g_object_unref (sniffer->priv->sniffer);
- if (sniffer->priv->msg)
- g_object_unref (sniffer->priv->msg);
- if (sniffer->priv->buffer)
- g_free (sniffer->priv->buffer);
- if (sniffer->priv->error)
- g_error_free (sniffer->priv->error);
- if (sniffer->priv->sniffed_type)
- g_free (sniffer->priv->sniffed_type);
- if (sniffer->priv->sniffed_params)
- g_hash_table_unref (sniffer->priv->sniffed_params);
+ g_clear_object (&sniffer->priv->sniffer);
+ g_clear_object (&sniffer->priv->msg);
+ g_free (sniffer->priv->buffer);
+ g_clear_error (&sniffer->priv->error);
+ g_free (sniffer->priv->sniffed_type);
+ g_clear_pointer (&sniffer->priv->sniffed_params, g_hash_table_unref);
G_OBJECT_CLASS (soup_content_sniffer_stream_parent_class)->finalize (object);
}
diff --git a/libsoup/soup-converter-wrapper.c b/libsoup/soup-converter-wrapper.c
index 4160c5f0..3ca45ad4 100644
--- a/libsoup/soup-converter-wrapper.c
+++ b/libsoup/soup-converter-wrapper.c
@@ -52,8 +52,7 @@ soup_converter_wrapper_finalize (GObject *object)
{
SoupConverterWrapperPrivate *priv = SOUP_CONVERTER_WRAPPER (object)->priv;
- if (priv->base_converter)
- g_object_unref (priv->base_converter);
+ g_clear_object (&priv->base_converter);
G_OBJECT_CLASS (soup_converter_wrapper_parent_class)->finalize (object);
}
diff --git a/libsoup/soup-cookie.c b/libsoup/soup-cookie.c
index fbf3ac89..f148afa4 100755
--- a/libsoup/soup-cookie.c
+++ b/libsoup/soup-cookie.c
@@ -841,9 +841,7 @@ soup_cookie_free (SoupCookie *cookie)
g_free (cookie->value);
g_free (cookie->domain);
g_free (cookie->path);
-
- if (cookie->expires)
- soup_date_free (cookie->expires);
+ g_clear_pointer (&cookie->expires, soup_date_free);
g_slice_free (SoupCookie, cookie);
}
diff --git a/libsoup/soup-filter-input-stream.c b/libsoup/soup-filter-input-stream.c
index 52ec6cd4..f8c1ab9f 100644
--- a/libsoup/soup-filter-input-stream.c
+++ b/libsoup/soup-filter-input-stream.c
@@ -44,8 +44,7 @@ finalize (GObject *object)
{
SoupFilterInputStream *fstream = SOUP_FILTER_INPUT_STREAM (object);
- if (fstream->priv->buf)
- g_byte_array_free (fstream->priv->buf, TRUE);
+ g_clear_pointer (&fstream->priv->buf, g_byte_array_unref);
G_OBJECT_CLASS (soup_filter_input_stream_parent_class)->finalize (object);
}
diff --git a/libsoup/soup-io-stream.c b/libsoup/soup-io-stream.c
index 7c114a99..3ade3db7 100644
--- a/libsoup/soup-io-stream.c
+++ b/libsoup/soup-io-stream.c
@@ -103,8 +103,7 @@ soup_io_stream_finalize (GObject *object)
{
SoupIOStream *siostream = SOUP_IO_STREAM (object);
- if (siostream->priv->base_iostream)
- g_object_unref (siostream->priv->base_iostream);
+ g_clear_object (&siostream->priv->base_iostream);
G_OBJECT_CLASS (soup_io_stream_parent_class)->finalize (object);
}
diff --git a/libsoup/soup-message-headers.c b/libsoup/soup-message-headers.c
index 2fd384c7..60033e1e 100644
--- a/libsoup/soup-message-headers.c
+++ b/libsoup/soup-message-headers.c
@@ -103,8 +103,7 @@ soup_message_headers_free (SoupMessageHeaders *hdrs)
if (--hdrs->ref_count == 0) {
soup_message_headers_clear (hdrs);
g_array_free (hdrs->array, TRUE);
- if (hdrs->concat)
- g_hash_table_destroy (hdrs->concat);
+ g_clear_pointer (&hdrs->concat, g_hash_table_destroy);
g_slice_free (SoupMessageHeaders, hdrs);
}
}
diff --git a/libsoup/soup-message.c b/libsoup/soup-message.c
index 3da4e693..0d025a1b 100644
--- a/libsoup/soup-message.c
+++ b/libsoup/soup-message.c
@@ -165,24 +165,18 @@ finalize (GObject *object)
if (priv->chunk_allocator_dnotify)
priv->chunk_allocator_dnotify (priv->chunk_allocator_data);
- if (priv->uri)
- soup_uri_free (priv->uri);
- if (priv->first_party)
- soup_uri_free (priv->first_party);
- if (priv->addr)
- g_object_unref (priv->addr);
+ g_clear_pointer (&priv->uri, soup_uri_free);
+ g_clear_pointer (&priv->first_party, soup_uri_free);
+ g_clear_object (&priv->addr);
- if (priv->auth)
- g_object_unref (priv->auth);
- if (priv->proxy_auth)
- g_object_unref (priv->proxy_auth);
+ g_clear_object (&priv->auth);
+ g_clear_object (&priv->proxy_auth);
g_slist_free (priv->disabled_features);
g_slist_free_full (priv->decoders, g_object_unref);
- if (priv->tls_certificate)
- g_object_unref (priv->tls_certificate);
+ g_clear_object (&priv->tls_certificate);
soup_message_body_free (msg->request_body);
soup_message_headers_free (msg->request_headers);
diff --git a/libsoup/soup-proxy-resolver-default.c b/libsoup/soup-proxy-resolver-default.c
index 58be8ab2..8e33e8bf 100644
--- a/libsoup/soup-proxy-resolver-default.c
+++ b/libsoup/soup-proxy-resolver-default.c
@@ -83,8 +83,7 @@ soup_proxy_resolver_default_finalize (GObject *object)
{
SoupProxyResolverDefaultPrivate *priv = SOUP_PROXY_RESOLVER_DEFAULT_GET_PRIVATE (object);
- if (priv->gproxy_resolver)
- g_object_unref (priv->gproxy_resolver);
+ g_clear_object (&priv->gproxy_resolver);
G_OBJECT_CLASS (soup_proxy_resolver_default_parent_class)->finalize (object);
}
diff --git a/libsoup/soup-proxy-resolver-static.c b/libsoup/soup-proxy-resolver-static.c
index 2c1f3e98..9b702d45 100644
--- a/libsoup/soup-proxy-resolver-static.c
+++ b/libsoup/soup-proxy-resolver-static.c
@@ -64,8 +64,7 @@ finalize (GObject *object)
SoupProxyResolverStaticPrivate *priv =
SOUP_PROXY_RESOLVER_STATIC_GET_PRIVATE (object);
- if (priv->proxy_uri)
- soup_uri_free (priv->proxy_uri);
+ g_clear_pointer (&priv->proxy_uri, soup_uri_free);
G_OBJECT_CLASS (soup_proxy_resolver_static_parent_class)->finalize (object);
}
diff --git a/libsoup/soup-request-file.c b/libsoup/soup-request-file.c
index 0627afca..3c5ddc00 100644
--- a/libsoup/soup-request-file.c
+++ b/libsoup/soup-request-file.c
@@ -56,8 +56,7 @@ soup_request_file_finalize (GObject *object)
{
SoupRequestFile *file = SOUP_REQUEST_FILE (object);
- if (file->priv->gfile)
- g_object_unref (file->priv->gfile);
+ g_clear_object (&file->priv->gfile);
g_free (file->priv->mime_type);
G_OBJECT_CLASS (soup_request_file_parent_class)->finalize (object);
diff --git a/libsoup/soup-request.c b/libsoup/soup-request.c
index 5e978419..df855ae5 100644
--- a/libsoup/soup-request.c
+++ b/libsoup/soup-request.c
@@ -78,10 +78,8 @@ soup_request_finalize (GObject *object)
{
SoupRequest *request = SOUP_REQUEST (object);
- if (request->priv->uri)
- soup_uri_free (request->priv->uri);
- if (request->priv->session)
- g_object_unref (request->priv->session);
+ g_clear_pointer (&request->priv->uri, soup_uri_free);
+ g_clear_object (&request->priv->session);
G_OBJECT_CLASS (soup_request_parent_class)->finalize (object);
}
diff --git a/libsoup/soup-server.c b/libsoup/soup-server.c
index d04b5d1d..8ba0eaac 100644
--- a/libsoup/soup-server.c
+++ b/libsoup/soup-server.c
@@ -166,18 +166,15 @@ finalize (GObject *object)
SoupServer *server = SOUP_SERVER (object);
SoupServerPrivate *priv = SOUP_SERVER_GET_PRIVATE (server);
- if (priv->iface)
- g_object_unref (priv->iface);
+ g_clear_object (&priv->iface);
g_free (priv->ssl_cert_file);
g_free (priv->ssl_key_file);
- if (priv->ssl_cert)
- g_object_unref (priv->ssl_cert);
+ g_clear_object (&priv->ssl_cert);
g_free (priv->server_header);
- if (priv->listen_sock)
- g_object_unref (priv->listen_sock);
+ g_clear_object (&priv->listen_sock);
while (priv->clients) {
SoupClientContext *client = priv->clients->data;
@@ -203,16 +200,13 @@ finalize (GObject *object)
soup_client_context_unref (client);
}
- if (priv->default_handler)
- free_handler (priv->default_handler);
+ g_clear_pointer (&priv->default_handler, free_handler);
soup_path_map_free (priv->handlers);
g_slist_free_full (priv->auth_domains, g_object_unref);
- if (priv->loop)
- g_main_loop_unref (priv->loop);
- if (priv->async_context)
- g_main_context_unref (priv->async_context);
+ g_clear_pointer (&priv->loop, g_main_loop_unref);
+ g_clear_pointer (&priv->async_context, g_main_context_unref);
G_OBJECT_CLASS (soup_server_parent_class)->finalize (object);
}
diff --git a/libsoup/soup-session.c b/libsoup/soup-session.c
index ef28892c..3d22660d 100644
--- a/libsoup/soup-session.c
+++ b/libsoup/soup-session.c
@@ -265,12 +265,10 @@ finalize (GObject *object)
g_free (priv->user_agent);
g_free (priv->accept_language);
- if (priv->tlsdb)
- g_object_unref (priv->tlsdb);
+ g_clear_object (&priv->tlsdb);
g_free (priv->ssl_ca_file);
- if (priv->async_context)
- g_main_context_unref (priv->async_context);
+ g_clear_pointer (&priv->async_context, g_main_context_unref);
g_hash_table_destroy (priv->features_cache);
diff --git a/libsoup/soup-socket.c b/libsoup/soup-socket.c
index feb11626..ca66dacb 100644
--- a/libsoup/soup-socket.c
+++ b/libsoup/soup-socket.c
@@ -158,18 +158,15 @@ finalize (GObject *object)
g_clear_object (&priv->istream);
g_clear_object (&priv->ostream);
- if (priv->local_addr)
- g_object_unref (priv->local_addr);
- if (priv->remote_addr)
- g_object_unref (priv->remote_addr);
+ g_clear_object (&priv->local_addr);
+ g_clear_object (&priv->remote_addr);
if (priv->watch_src) {
if (priv->clean_dispose && !priv->is_server)
g_warning ("Disposing socket %p during async op", object);
g_source_destroy (priv->watch_src);
}
- if (priv->async_context)
- g_main_context_unref (priv->async_context);
+ g_clear_pointer (&priv->async_context, g_main_context_unref);
g_mutex_clear (&priv->addrlock);
g_mutex_clear (&priv->iolock);