From dc1cfa6252073ac345412e7df9c5cc0365bb7f11 Mon Sep 17 00:00:00 2001 From: Szczepan Zalega Date: Tue, 28 Jul 2020 12:29:43 +0200 Subject: Extract Nitrokey Storage only features to separate unit --- nk_strndup.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 nk_strndup.c (limited to 'nk_strndup.c') diff --git a/nk_strndup.c b/nk_strndup.c new file mode 100644 index 0000000..e24c584 --- /dev/null +++ b/nk_strndup.c @@ -0,0 +1,14 @@ +#include "nk_strndup.h" + +#ifndef strndup +#ifdef _WIN32 +#pragma message "Using own strndup" +char * strndup(const char* str, size_t maxlen){ + size_t len = strnlen(str, maxlen); + char* dup = (char *) malloc(len + 1); + memcpy(dup, str, len); + dup[len] = 0; + return dup; +} +#endif +#endif \ No newline at end of file -- cgit v1.2.1