mirror of https://git.musl-libc.org/git/musl
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
12 lines
197 B
12 lines
197 B
#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;
|
|
}
|
|
|