fxlibc/src/string/strdup.c

11 lines
175 B
C
Raw Permalink Normal View History

2021-05-09 17:34:00 +02:00
#include <string.h>
#include <stdlib.h>
2020-09-17 19:27:01 +02:00
char *strdup(char const *s)
2020-09-17 19:27:01 +02:00
{
size_t len = strlen(s) + 1;
char *copy = malloc(len);
if(copy) memcpy(copy, s, len);
return copy;
2020-09-17 19:27:01 +02:00
}