[librest/wip/teuf/gtask: 11/28] RestProxy(Call): Simplify _dispose



commit 5c98143086a37b728ac187a934028e650d1a6c0f
Author: Timm Bäder <mail baedert org>
Date:   Sat Apr 23 16:06:01 2016 +0200

    RestProxy(Call): Simplify _dispose

 rest/rest-proxy-call.c |   27 ++++-----------------------
 rest/rest-proxy.c      |    6 +-----
 2 files changed, 5 insertions(+), 28 deletions(-)
---
diff --git a/rest/rest-proxy-call.c b/rest/rest-proxy-call.c
index 7abf367..4a5425a 100644
--- a/rest/rest-proxy-call.c
+++ b/rest/rest-proxy-call.c
@@ -144,29 +144,10 @@ rest_proxy_call_dispose (GObject *object)
       g_clear_object (&priv->cancellable);
     }
 
-  if (priv->params)
-  {
-    rest_params_free (priv->params);
-    priv->params = NULL;
-  }
-
-  if (priv->headers)
-  {
-    g_hash_table_unref (priv->headers);
-    priv->headers = NULL;
-  }
-
-  if (priv->response_headers)
-  {
-    g_hash_table_unref (priv->response_headers);
-    priv->response_headers = NULL;
-  }
-
-  if (priv->proxy)
-  {
-    g_object_unref (priv->proxy);
-    priv->proxy = NULL;
-  }
+  g_clear_pointer (&priv->params, rest_params_free);
+  g_clear_pointer (&priv->headers, g_hash_table_unref);
+  g_clear_pointer (&priv->response_headers, g_hash_table_unref);
+  g_clear_object (&priv->proxy);
 
   G_OBJECT_CLASS (rest_proxy_call_parent_class)->dispose (object);
 }
diff --git a/rest/rest-proxy.c b/rest/rest-proxy.c
index d79d204..9061221 100644
--- a/rest/rest-proxy.c
+++ b/rest/rest-proxy.c
@@ -194,11 +194,7 @@ rest_proxy_dispose (GObject *object)
 {
   RestProxyPrivate *priv = GET_PRIVATE (object);
 
-  if (priv->session)
-  {
-    g_object_unref (priv->session);
-    priv->session = NULL;
-  }
+  g_clear_object (&priv->session);
 
   G_OBJECT_CLASS (rest_proxy_parent_class)->dispose (object);
 }


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