zig/lib/libc/musl/src/string/strndup.c
Andrew Kelley 49d1a4c562 move lib dirs to lib subdir
also start prefering NtDll API. so far:
 * NtQueryInformationFile
 * NtClose

adds a performance workaround for windows unicode conversion. but that
should probably be removed before merging
2019-07-15 17:54:50 -04:00

13 lines
197 B
C

#include <stdlib.h>
#include <string.h>
char *strndup(const char *s, size_t n)
{
size_t l = strnlen(s, n);
char *d = malloc(l+1);
if (!d) return NULL;
memcpy(d, s, l);
d[l] = 0;
return d;
}