]> granicus.if.org Git - libevent/commitdiff
Add missing strndup function on Windows to fix build on MSVC 2022
authorWilliam Marlow <william.marlow@ibm.com>
Sat, 18 Jun 2022 20:43:31 +0000 (21:43 +0100)
committerAzat Khuzhin <azat@libevent.org>
Sat, 9 Jul 2022 10:16:00 +0000 (13:16 +0300)
v2: Only define strndup on non-Mingw32 Windows

sample/https-client.c

index 85433850e84cb7290fe762e225ed70c57aabefb1..f7490cdb1d40860cb418250e92a1cf634354a59f 100644 (file)
@@ -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)
 {