From e4c0319d2703a5a0f74e3173daec7a5298ac1fa9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Hrdli=C4=8Dka?= Date: Sun, 31 Jan 2021 17:27:19 +0100 Subject: [PATCH] tinyglib: change `g_strdup` to a macro --- src/include/tinyglib.h | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) diff --git a/src/include/tinyglib.h b/src/include/tinyglib.h index 686257e7f..24f9409a3 100644 --- a/src/include/tinyglib.h +++ b/src/include/tinyglib.h @@ -215,24 +215,6 @@ g_strv_length(gchar **str_array) } -/* Implementation borrowed from GLib itself. */ -static gchar* -g_strdup(const gchar *str) -{ - gchar *new_str; - gsize length; - - if (str) { - length = strlen(str) + 1; - new_str = malloc(sizeof(char) * length); - memcpy(new_str, str, length); - } else - new_str = NULL; - - return new_str; -} - - /* Macros */ #define tinyglib_pclog(f, s, ...) pclog("TinyGLib " f "(): " s "\n", ##__VA_ARGS__) @@ -289,6 +271,7 @@ g_strdup(const gchar *str) #define g_rand_free free #define g_realloc realloc #define g_snprintf snprintf +#define g_strdup(str) str ? strdup(str) : NULL #define g_strerror strerror #define g_strfreev free #define g_string_append_printf sprintf /* unimplemented */