[Libosinfo] [libosinfo PATCH v2 1/3] tree: Use g_clear_object in create_from_location_async_data_free()

Fabiano Fidêncio fidencio at redhat.com
Wed Jul 17 12:24:48 UTC 2019


We should check whether the objects are NULL or not before calling
g_object_unref(). Instead of doing so, let's use g_clear_object(), which
doesn't require the check.

Signed-off-by: Fabiano Fidêncio <fidencio at redhat.com>
---
 osinfo/osinfo_tree.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/osinfo/osinfo_tree.c b/osinfo/osinfo_tree.c
index 8e98f6c..03b6f3b 100644
--- a/osinfo/osinfo_tree.c
+++ b/osinfo/osinfo_tree.c
@@ -47,9 +47,9 @@ struct _CreateFromLocationAsyncData {
 
 static void create_from_location_async_data_free(CreateFromLocationAsyncData *data)
 {
-    g_object_unref(data->session);
-    g_object_unref(data->message);
-    g_object_unref(data->res);
+    g_clear_object(&data->session);
+    g_clear_object(&data->message);
+    g_clear_object(&data->res);
 
     g_slice_free(CreateFromLocationAsyncData, data);
 }
-- 
2.21.0




More information about the Libosinfo mailing list