[gnome-bluetooth/wip/hadess/cleanups: 4/11] lib: Use g_clear_* to simplify some code




commit b7cbc8f86bdabad717bd53d7e14318c2e89ea388
Author: Bastien Nocera <hadess hadess net>
Date:   Wed Feb 10 16:34:32 2021 +0100

    lib: Use g_clear_* to simplify some code

 lib/bluetooth-agent.c | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)
---
diff --git a/lib/bluetooth-agent.c b/lib/bluetooth-agent.c
index db0f41c2..6b893338 100644
--- a/lib/bluetooth-agent.c
+++ b/lib/bluetooth-agent.c
@@ -331,8 +331,7 @@ name_vanished_cb (GDBusConnection *connection,
 {
        BluetoothAgentPrivate *priv = BLUETOOTH_AGENT_GET_PRIVATE(agent);
 
-       g_free (priv->busname);
-       priv->busname = NULL;
+       g_clear_pointer (&priv->busname, g_free);
        g_clear_object (&priv->agent_manager);
 }
 
@@ -578,14 +577,9 @@ gboolean bluetooth_agent_unregister(BluetoothAgent *agent)
                }
        }
 
-       g_object_unref(priv->agent_manager);
-       priv->agent_manager = NULL;
-
-       g_free(priv->path);
-       priv->path = NULL;
-
-       g_free(priv->busname);
-       priv->busname = NULL;
+       g_clear_object (&priv->agent_manager);
+       g_clear_pointer (&priv->path, g_free);
+       g_clear_pointer (&priv->busname, g_free);
 
        if (priv->reg_id > 0) {
                g_dbus_connection_unregister_object (priv->conn, priv->reg_id);


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