From e43376df2a4d01230f3d07b22eb2dd34e2c70806 Mon Sep 17 00:00:00 2001 From: William Marlow Date: Sat, 18 Jun 2022 21:43:31 +0100 Subject: [PATCH] Add missing strndup function on Windows to fix build on MSVC 2022 v2: Only define strndup on non-Mingw32 Windows --- sample/https-client.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/sample/https-client.c b/sample/https-client.c index 85433850..f7490cdb 100644 --- a/sample/https-client.c +++ b/sample/https-client.c @@ -247,6 +247,17 @@ add_cert_for_store(X509_STORE *store, const char *name) } #endif +#if defined(_WIN32) && !defined(__MINGW32__) +char* strndup(const char* src, size_t chars) { + char* buffer = (char*) malloc(chars + 1); + if (buffer) { + strncpy(buffer, src, chars); + buffer[chars] = '\0'; + } + return buffer; +} +#endif + int main(int argc, char **argv) { -- 2.40.0