From 7b049d47d980b87299d830b8f1c00516fa6a8ebc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A1szl=C3=B3=20V=C3=A1rady?= Date: Tue, 19 Nov 2024 19:00:22 +0100 Subject: [PATCH] glib-compat: add g_hash_table_steal_extended() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: László Várady --- lib/compat/glib.c | 11 +++++++++++ lib/compat/glib.h | 6 ++++++ 2 files changed, 17 insertions(+) diff --git a/lib/compat/glib.c b/lib/compat/glib.c index d701e93ea0..54676d741e 100644 --- a/lib/compat/glib.c +++ b/lib/compat/glib.c @@ -297,3 +297,14 @@ g_utf8_get_char_validated_fixed(const gchar *p, gssize max_len) return g_utf8_get_char_validated(p, max_len); } #endif + + +#if !GLIB_CHECK_VERSION(2, 58, 0) +gboolean +slng_g_hash_table_steal_extended(GHashTable *hash_table, gconstpointer lookup_key, + gpointer *stolen_key, gpointer *stolen_value) +{ + g_hash_table_lookup_extended(hash_table, lookup_key, stolen_key, stolen_value); + return g_hash_table_steal(hash_table, lookup_key); +} +#endif diff --git a/lib/compat/glib.h b/lib/compat/glib.h index 18227fb66a..eee890e828 100644 --- a/lib/compat/glib.h +++ b/lib/compat/glib.h @@ -68,4 +68,10 @@ gunichar g_utf8_get_char_validated_fixed (const gchar *p, gssize max_len); #define g_pattern_spec_match g_pattern_match #endif +#if !GLIB_CHECK_VERSION(2, 58, 0) +#define g_hash_table_steal_extended slng_g_hash_table_steal_extended +gboolean slng_g_hash_table_steal_extended(GHashTable *hash_table, gconstpointer lookup_key, + gpointer *stolen_key, gpointer *stolen_value); +#endif + #endif