mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-02-22 18:22:11 +01:00
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:
parent
f3701217c7
commit
aeb13ae9be
@ -95,6 +95,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "glib-private.h"
|
||||
#include "gdbusauth.h"
|
||||
#include "gdbusutils.h"
|
||||
#include "gdbusaddress.h"
|
||||
|
@ -105,4 +105,22 @@ GLibPrivateVTable *glib__private__ (void);
|
||||
# define GLIB_DEFAULT_LOCALE ""
|
||||
#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__ */
|
||||
|
Loading…
x
Reference in New Issue
Block a user