Don't rely on strdup / cygwin fix

This commit is contained in:
Evan Miller 2020-08-05 09:35:19 -04:00
parent f1af742ecf
commit 05092351df
2 changed files with 8 additions and 8 deletions

View File

@ -4,7 +4,6 @@
#include <time.h>
#include <locale.h>
#include <inttypes.h>
#include <string.h>
#include <strings.h>
// for ntohl
@ -96,12 +95,6 @@ typedef struct GOptionContext {
#define g_free free
#define g_realloc realloc
#if defined _WIN32
#define g_strdup _strdup
#else
#define g_strdup strdup
#endif
#define G_STR_DELIMITERS "_-|> <."
#define g_ptr_array_index(array, i) \
@ -125,6 +118,7 @@ int g_str_equal(const void *str1, const void *str2);
char **g_strsplit(const char *haystack, const char *needle, int something);
void g_strfreev(char **dir);
char *g_strconcat(const char *first, ...);
char *g_strdup(const char *src);
char *g_strdup_printf(const char *format, ...);
gchar *g_strdelimit(gchar *string, const gchar *delimiters, gchar new_delimiter);

View File

@ -5,6 +5,7 @@
#include <stdlib.h>
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
#include <getopt.h>
/* string functions */
@ -101,12 +102,17 @@ int vasprintf(char **ret, const char *format, va_list ap) {
}
#endif
char *g_strdup(const char *input) {
size_t len = strlen(input);
return g_memdup(input, len+1);
}
char *g_strdup_printf(const char *format, ...) {
char *ret = NULL;
va_list argp;
va_start(argp, format);
#ifdef ___CYGWIN__
#ifdef __CYGWIN__
size_t len = 0;
vasnprintf(&ret, &len, format, argp);
#else