mirror of
https://git.planet-casio.com/Vhex-Kernel-Core/fxlibc.git
synced 2025-04-30 06:59:18 +02:00
15 lines
220 B
C
15 lines
220 B
C
#include <string.h>
|
|
#include <stdlib.h>
|
|
|
|
char *strndup(const char *s, size_t n)
|
|
{
|
|
size_t len = strnlen(s, n) + 1;
|
|
char *copy = malloc(len);
|
|
|
|
if(copy) {
|
|
memcpy(copy, s, len);
|
|
copy[len - 1] = 0;
|
|
}
|
|
|
|
return copy;
|
|
}
|