aboutsummaryrefslogtreecommitdiff
path: root/nk_strndup.c
blob: e24c584f3a0c7f28efd7f0b56f36c4f3630eb570 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
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