From ac41df5ee5c08fc461a36d8d27ff69663ba7f6e1 Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Fri, 16 Aug 2024 10:23:51 -0400 Subject: [PATCH] MT#55283 handle g_memdup2 legacy Change-Id: I61ebca94924e7abdda01ce4d4bd99cef8cddfd81 --- daemon/redis.c | 2 +- lib/str.h | 6 +----- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/daemon/redis.c b/daemon/redis.c index b10186ff1a..0f8fdbe078 100644 --- a/daemon/redis.c +++ b/daemon/redis.c @@ -1025,7 +1025,7 @@ static void json_get_hash_iter(const ng_parser_t *parser, str *key, parser_arg v } // XXX convert to proper str ht - char *tmp = g_memdup2(key->s, key->len + 1); + char *tmp = __g_memdup(key->s, key->len + 1); tmp[key->len] = '\0'; // XXX eliminate string dup? eliminate URI decode? if (g_hash_table_insert(arg.ht, tmp, str_uri_decode_len(val.s, val.len)) != TRUE) diff --git a/lib/str.h b/lib/str.h index cac4ea5d7a..a8ba82b331 100644 --- a/lib/str.h +++ b/lib/str.h @@ -42,11 +42,7 @@ TYPED_GQUEUE(str, str) #define STR_GS(s) ((str) { (s)->str, (s)->len }) #define STR_LEN(s, len) ((str) { (char *) (s), len }) #define STR_LEN_ASSERT(s, len) ({ assert(sizeof(s) >= len); (str) { (char *) (s), len }; }) -#if GLIB_CHECK_VERSION(2,68,0) -#define STR_DUP(s) ({ size_t __l = strlen(s); (str) { g_memdup2(s, __l + 1), __l }; }) -#else -#define STR_DUP(s) ((str) { g_strdup(s), strlen(s) }) -#endif +#define STR_DUP(s) ({ size_t __l = strlen(s); (str) { __g_memdup(s, __l + 1), __l }; }) #define STR_CONST_BUF(buf) ((str) { (char *) &buf, sizeof(buf) })