From 27d51c3250a54d19cd5bda1411450fbbb8218113 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Fri, 20 Dec 2019 12:40:45 +0100 Subject: [PATCH] shared/glib: add compat implementation for g_hash_table_steal_extended() --- shared/nm-glib-aux/nm-glib.h | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/shared/nm-glib-aux/nm-glib.h b/shared/nm-glib-aux/nm-glib.h index dfb75bf05f..e7e69dc5fe 100644 --- a/shared/nm-glib-aux/nm-glib.h +++ b/shared/nm-glib-aux/nm-glib.h @@ -601,4 +601,32 @@ _g_atomic_pointer_compare_and_exchange (volatile void *atomic, /*****************************************************************************/ +#if !GLIB_CHECK_VERSION (2, 58, 0) +static inline gboolean +g_hash_table_steal_extended (GHashTable *hash_table, + gconstpointer lookup_key, + gpointer *stolen_key, + gpointer *stolen_value) +{ + if (g_hash_table_lookup_extended (hash_table, lookup_key, stolen_key, stolen_value)) { + g_hash_table_steal (hash_table, lookup_key); + return TRUE; + } + if (stolen_key) + *stolen_key = NULL; + if (stolen_value) + *stolen_value = NULL; + return FALSE; +} +#else +#define g_hash_table_steal_extended(hash_table, lookup_key, stolen_key, stolen_value) \ + ({ \ + G_GNUC_BEGIN_IGNORE_DEPRECATIONS \ + g_hash_table_steal_extended (hash_table, lookup_key, stolen_key, stolen_value); \ + G_GNUC_END_IGNORE_DEPRECATIONS \ + }) +#endif + +/*****************************************************************************/ + #endif /* __NM_GLIB_H__ */