From 667ad4c57b28bbff44ceab65021358d2abe7cdc7 Mon Sep 17 00:00:00 2001 From: Sebastian Wick Date: Fri, 9 May 2025 00:08:47 +0200 Subject: [PATCH] glib-backports: Add g_set_str from 2.84.1 --- common/flatpak-glib-backports-private.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/common/flatpak-glib-backports-private.h b/common/flatpak-glib-backports-private.h index d030aaf9..8adb54aa 100644 --- a/common/flatpak-glib-backports-private.h +++ b/common/flatpak-glib-backports-private.h @@ -172,4 +172,24 @@ guint g_string_replace (GString *string, # define G_DBUS_METHOD_INVOCATION_UNHANDLED FALSE #endif +#if !GLIB_CHECK_VERSION (2, 76, 0) +/* All this code is backported directly from 2.84.1 */ +static inline gboolean +g_set_str (char **str_pointer, + const char *new_str) +{ + char *copy; + + if (*str_pointer == new_str || + (*str_pointer && new_str && strcmp (*str_pointer, new_str) == 0)) + return FALSE; + + copy = g_strdup (new_str); + g_free (*str_pointer); + *str_pointer = copy; + + return TRUE; +} +#endif /* GLIB_CHECK_VERSION (2, 76, 0) */ + G_END_DECLS