gdbusconnection: Make a backport of g_set_str() available

A subsequent commit will need this. Copying all of g_set_str() into a
private header seems cleaner than replacing the call to it.

Helps: GNOME/glib#3268
Signed-off-by: Simon McVittie <smcv@collabora.com>
This commit is contained in:
Simon McVittie 2024-05-01 15:51:42 +01:00 committed by Marco Trevisan (Treviño)
parent c4e3022918
commit c805fd3862
2 changed files with 19 additions and 0 deletions

View File

@ -95,6 +95,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include "glib-private.h"
#include "gdbusauth.h" #include "gdbusauth.h"
#include "gdbusutils.h" #include "gdbusutils.h"
#include "gdbusaddress.h" #include "gdbusaddress.h"

View File

@ -201,4 +201,22 @@ GLibPrivateVTable *glib__private__ (void);
# define GLIB_DEFAULT_LOCALE "" # define GLIB_DEFAULT_LOCALE ""
#endif #endif
/* Backported from GLib 2.78.x, where it is public API in gstrfuncs.h */
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_PRIVATE_H__ */ #endif /* __GLIB_PRIVATE_H__ */