[sysprof/wip/chergert/sysprof-3] libsysprof: use macro to preserve types



commit 64ada6fad0bd1c7e788dd6e4609f69672ae183c2
Author: Christian Hergert <chergert redhat com>
Date:   Fri May 10 19:36:29 2019 -0700

    libsysprof: use macro to preserve types

 src/libsysprof/sysprof-backport-autocleanups.h | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)
---
diff --git a/src/libsysprof/sysprof-backport-autocleanups.h b/src/libsysprof/sysprof-backport-autocleanups.h
index 51eaba8..bba89ca 100644
--- a/src/libsysprof/sysprof-backport-autocleanups.h
+++ b/src/libsysprof/sysprof-backport-autocleanups.h
@@ -13,13 +13,11 @@
 #endif
 
 #if !GLIB_CHECK_VERSION(2, 56, 0)
-  static inline void
-  g_clear_handle_id (guint *ptr,
-                     void (*clear_func) (guint handle_id))
-  {
-    guint id = *ptr;
-    *ptr = 0;
-    if (id)
-      clear_func (handle_id);
-  }
+# define g_clear_handle_id(ptr, clear_func) \
+    G_STMT_START {                          \
+      guint __ptr = *(ptr);                 \
+      *(ptr) = 0;                           \
+      if (__ptr != 0)                       \
+        clear_func (__ptr);                 \
+    } G_STMT_END
 #endif


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