[gnome-bluetooth/wip/hadess/cleanups: 12/24] lib: Use g_clear_* to simplify some code
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-bluetooth/wip/hadess/cleanups: 12/24] lib: Use g_clear_* to simplify some code
- Date: Wed, 17 Feb 2021 11:02:24 +0000 (UTC)
commit d9e994a83ba0ef3e1fa5dcc59d95bb6e6f744465
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 ++++----------
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);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]