From 939814826f3eeee988f81313cd5881c6d08d6116 Mon Sep 17 00:00:00 2001 From: Daniel Abrecht Date: Sun, 3 Oct 2021 12:51:42 +0000 Subject: [PATCH] Fix mingw build: add strndup implementation to win32_compat.c --- include/win32/win32_compat.h | 5 +++++ win32/win32_compat.c | 19 ++++++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/include/win32/win32_compat.h b/include/win32/win32_compat.h index d57d35c..bf3295e 100755 --- a/include/win32/win32_compat.h +++ b/include/win32/win32_compat.h @@ -33,6 +33,7 @@ THE SOFTWARE. #include #include #include +#include // For size_t type typedef unsigned long fsblkcnt_t; typedef unsigned long fsfilcnt_t; @@ -151,4 +152,8 @@ int win32_gettimeofday(struct timeval *tv, struct timezone *tz); #define DllExport +#ifdef __MINGW32__ +char* strndup(const char *s, size_t n); +#endif + #endif//win32_COMPAT_H_ diff --git a/win32/win32_compat.c b/win32/win32_compat.c index d1066e3..86171e9 100644 --- a/win32/win32_compat.c +++ b/win32/win32_compat.c @@ -197,6 +197,23 @@ int win32_gettimeofday(struct timeval *tv, struct timezone *tz) return 0; } +#endif + +#ifdef __MINGW32__ +char* strndup(const char* s, size_t n) +{ + size_t len; + for(len=0; len