diff options
author | Christopher Davis <christopherdavis@gnome.org> | 2022-12-15 23:08:35 -0500 |
---|---|---|
committer | Christopher Davis <christopherdavis@gnome.org> | 2022-12-16 10:16:52 -0500 |
commit | 3e86bc65f5d482b4e512b802739cc2d5217e4b38 (patch) | |
tree | 5b2e62e688939824a3d88985f6c35ef5644ec5a4 /gdk | |
parent | 2442ed87fe42474e6a5f8b51cd8e89c7df7b7276 (diff) | |
download | gtk+-3e86bc65f5d482b4e512b802739cc2d5217e4b38.tar.gz |
gdkprivate: Add compatibility shim for g_set_str()
Allows us to make use of this API without depending
on bleeding-edge glib
Diffstat (limited to 'gdk')
-rw-r--r-- | gdk/gdkprivate.h | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/gdk/gdkprivate.h b/gdk/gdkprivate.h index 0f37cb0d8b..9501394743 100644 --- a/gdk/gdkprivate.h +++ b/gdk/gdkprivate.h @@ -23,4 +23,23 @@ void gdk_source_set_static_name_by_id (guint tag, #define I_(string) g_intern_static_string (string) #endif +#if !GLIB_CHECK_VERSION (2, 76, 0) +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 + #endif /* __GDK__PRIVATE_H__ */ |