diff options
author | Bastien Nocera <hadess@hadess.net> | 2021-02-10 16:34:32 +0100 |
---|---|---|
committer | Bastien Nocera <hadess@hadess.net> | 2021-02-17 12:02:14 +0100 |
commit | d9e994a83ba0ef3e1fa5dcc59d95bb6e6f744465 (patch) | |
tree | cf3d6ad6e43081ff5bfe0cebcf505e94328cb947 | |
parent | 91884e24f256c1ccd1520f2fa6fd1329c4e11dbb (diff) | |
download | gnome-bluetooth-d9e994a83ba0ef3e1fa5dcc59d95bb6e6f744465.tar.gz |
lib: Use g_clear_* to simplify some code
-rw-r--r-- | lib/bluetooth-agent.c | 14 | ||||
-rw-r--r-- | lib/bluetooth-filter-widget.c | 8 |
2 files changed, 6 insertions, 16 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); diff --git a/lib/bluetooth-filter-widget.c b/lib/bluetooth-filter-widget.c index d010bb68..bff90d81 100644 --- a/lib/bluetooth-filter-widget.c +++ b/lib/bluetooth-filter-widget.c @@ -328,8 +328,7 @@ bluetooth_filter_widget_finalize (GObject *object) { BluetoothFilterWidgetPrivate *priv = BLUETOOTH_FILTER_WIDGET_GET_PRIVATE(object); - g_free (priv->device_service_filter); - priv->device_service_filter = NULL; + g_clear_pointer (&filter->device_service_filter, g_free); G_OBJECT_CLASS(bluetooth_filter_widget_parent_class)->finalize(object); } @@ -339,10 +338,7 @@ bluetooth_filter_widget_dispose (GObject *object) { BluetoothFilterWidgetPrivate *priv = BLUETOOTH_FILTER_WIDGET_GET_PRIVATE(object); - if (priv->chooser) { - g_object_unref (priv->chooser); - priv->chooser = NULL; - } + g_clear_object (&filter->chooser); G_OBJECT_CLASS(bluetooth_filter_widget_parent_class)->dispose(object); } |