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.
13 lines
197 B
13 lines
197 B
|
15 years ago
|
#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;
|
||
|
|
}
|