fxlibc/src/string/strdup.c

11 lines
175 B
C

#include <string.h>
#include <stdlib.h>
char *strdup(char const *s)
{
size_t len = strlen(s) + 1;
char *copy = malloc(len);
if(copy) memcpy(copy, s, len);
return copy;
}