From cd0dd3b0bf6ca727c24bfa884941221f62fb138a Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Thu, 12 May 2016 14:25:36 +0200 Subject: [PATCH] nm-glib: backport g_steal_pointer() from glib-2.44 (cherry picked from commit 5d1c4ca6c40d5368f969424e5fe0aaacbc799502) --- shared/nm-glib.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/shared/nm-glib.h b/shared/nm-glib.h index c92d6f0f71..5f8ebc7fdc 100644 --- a/shared/nm-glib.h +++ b/shared/nm-glib.h @@ -374,4 +374,22 @@ _nm_g_hash_table_get_keys_as_array (GHashTable *hash_table, __VA_ARGS__) #endif +#if !GLIB_CHECK_VERSION(2, 44, 0) +static inline gpointer +g_steal_pointer (gpointer pp) +{ + gpointer *ptr = (gpointer *) pp; + gpointer ref; + + ref = *ptr; + *ptr = NULL; + + return ref; +} + +/* type safety */ +#define g_steal_pointer(pp) \ + (0 ? (*(pp)) : (g_steal_pointer) (pp)) +#endif + #endif /* __NM_GLIB_H__ */