summaryrefslogtreecommitdiff
path: root/sample
diff options
context:
space:
mode:
authorWilliam Marlow <william.marlow@ibm.com>2022-06-18 21:43:31 +0100
committerAzat Khuzhin <azat@libevent.org>2022-07-09 13:16:00 +0300
commite43376df2a4d01230f3d07b22eb2dd34e2c70806 (patch)
treedfded8ea086204a1c4825039b5589b6260b1f32a /sample
parentbf3ce77f6cf113839defa70b30e183d471a0dab5 (diff)
downloadlibevent-e43376df2a4d01230f3d07b22eb2dd34e2c70806.tar.gz
Add missing strndup function on Windows to fix build on MSVC 2022
v2: Only define strndup on non-Mingw32 Windows
Diffstat (limited to 'sample')
-rw-r--r--sample/https-client.c11
1 files changed, 11 insertions, 0 deletions
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)
{