diff options
Diffstat (limited to 'nk_strndup.c')
-rw-r--r-- | nk_strndup.c | 14 |
1 files changed, 14 insertions, 0 deletions
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 |