From f9bf5fb5f9a51cfee1e0529299cc761dfe405a96 Mon Sep 17 00:00:00 2001 From: Alexander Larsson Date: Fri, 12 Apr 2019 14:32:06 +0200 Subject: [PATCH] utils: Add backport of g_clear_handle_id to pre 2.56 glib --- common/flatpak-utils-private.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/common/flatpak-utils-private.h b/common/flatpak-utils-private.h index 91d4d9fd3..af574f726 100644 --- a/common/flatpak-utils-private.h +++ b/common/flatpak-utils-private.h @@ -322,6 +322,26 @@ g_date_time_new_from_iso8601 (const gchar *text, GTimeZone *default_tz) } #endif + +#if !GLIB_CHECK_VERSION (2, 56, 0) +typedef void (* GClearHandleFunc) (guint handle_id); + +static inline void +g_clear_handle_id (guint *tag_ptr, + GClearHandleFunc clear_func) +{ + guint _handle_id; + + _handle_id = *tag_ptr; + if (_handle_id > 0) + { + *tag_ptr = 0; + clear_func (_handle_id); + } +} +#endif + + #if !GLIB_CHECK_VERSION (2, 58, 0) static inline gboolean g_hash_table_steal_extended (GHashTable *hash_table,