From bc742bb1ad3a2dfe25639c21b0e4fb00f5f6f3d1 Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Mon, 27 Mar 2023 13:18:02 -0400 Subject: [PATCH] MT#56447 add wrapper g_hash_table_steal_extended Compatibility for glib versions older than 2.58 Change-Id: Ie212a1c08efa87f103b31eac31f81a3870e5cedd --- lib/auxlib.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/auxlib.h b/lib/auxlib.h index e2d40c69d..284ccf755 100644 --- a/lib/auxlib.h +++ b/lib/auxlib.h @@ -376,5 +376,17 @@ INLINE void g_tree_add_all(GTree *t, GQueue *q, void (*cb)(gpointer, gpointer)) # define __g_memdup(a,b) g_memdup2(a,b) #endif +#if !GLIB_CHECK_VERSION(2,58,0) +INLINE gboolean g_hash_table_steal_extended(GHashTable *ht, gconstpointer lookup, gpointer *ret_key, + gpointer *ret_val) +{ + gboolean found = g_hash_table_lookup_extended(ht, lookup, ret_key, ret_val); + if (!found) + return false; + g_hash_table_steal(ht, lookup); + return true; +} +#endif + #endif