[glib-networking] gnutls: use g_clear_object()
- From: Dan Winship <danw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib-networking] gnutls: use g_clear_object()
- Date: Wed, 18 Jul 2012 21:47:44 +0000 (UTC)
commit 7611ca4d847351b281fd37065e26bc06be021be1
Author: Dan Winship <danw gnome org>
Date: Thu Jun 28 11:35:46 2012 -0400
gnutls: use g_clear_object()
tls/gnutls/gtlsconnection-gnutls.c | 46 ++++++++++++++----------------------
1 files changed, 18 insertions(+), 28 deletions(-)
---
diff --git a/tls/gnutls/gtlsconnection-gnutls.c b/tls/gnutls/gtlsconnection-gnutls.c
index b8fc86c..3f872a9 100644
--- a/tls/gnutls/gtlsconnection-gnutls.c
+++ b/tls/gnutls/gtlsconnection-gnutls.c
@@ -224,39 +224,30 @@ g_tls_connection_gnutls_initable_init (GInitable *initable,
static void
g_tls_connection_gnutls_finalize (GObject *object)
{
- GTlsConnectionGnutls *connection = G_TLS_CONNECTION_GNUTLS (object);
-
- if (connection->priv->base_io_stream)
- g_object_unref (connection->priv->base_io_stream);
-
- if (connection->priv->session)
- gnutls_deinit (connection->priv->session);
-
- if (connection->priv->tls_istream)
- g_object_unref (connection->priv->tls_istream);
- if (connection->priv->tls_ostream)
- g_object_unref (connection->priv->tls_ostream);
+ GTlsConnectionGnutls *gnutls = G_TLS_CONNECTION_GNUTLS (object);
- if (connection->priv->creds)
- gnutls_certificate_free_credentials (connection->priv->creds);
+ g_clear_object (&gnutls->priv->base_io_stream);
- if (connection->priv->database)
- g_object_unref (connection->priv->database);
- if (connection->priv->certificate)
- g_object_unref (connection->priv->certificate);
- if (connection->priv->peer_certificate)
- g_object_unref (connection->priv->peer_certificate);
+ g_clear_object (&gnutls->priv->tls_istream);
+ g_clear_object (&gnutls->priv->tls_ostream);
- g_clear_object (&connection->priv->interaction);
+ if (gnutls->priv->session)
+ gnutls_deinit (gnutls->priv->session);
+ if (gnutls->priv->creds)
+ gnutls_certificate_free_credentials (gnutls->priv->creds);
- if (connection->priv->error)
- g_error_free (connection->priv->error);
+ g_clear_object (&gnutls->priv->database);
+ g_clear_object (&gnutls->priv->certificate);
+ g_clear_object (&gnutls->priv->peer_certificate);
#ifdef HAVE_PKCS11
- p11_kit_pin_unregister_callback (connection->priv->interaction_id,
- on_pin_prompt_callback, connection);
+ p11_kit_pin_unregister_callback (gnutls->priv->interaction_id,
+ on_pin_prompt_callback, gnutls);
#endif
- g_free (connection->priv->interaction_id);
+ g_free (gnutls->priv->interaction_id);
+ g_clear_object (&gnutls->priv->interaction);
+
+ g_clear_error (&gnutls->priv->error);
G_OBJECT_CLASS (g_tls_connection_gnutls_parent_class)->finalize (object);
}
@@ -804,8 +795,7 @@ handshake_internal (GTlsConnectionGnutls *gnutls,
if (gnutls->priv->peer_certificate)
{
- g_object_unref (gnutls->priv->peer_certificate);
- gnutls->priv->peer_certificate = NULL;
+ g_clear_object (&gnutls->priv->peer_certificate);
gnutls->priv->peer_certificate_errors = 0;
g_object_notify (G_OBJECT (gnutls), "peer-certificate");
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]