k-tana-zero/libs/libk/strdup.c
Julien CLEMENT 7178dbb6a7 feat: add given files
Signed-off-by: Julien CLEMENT <julien.clement@epita.fr>
2021-07-12 15:57:08 +02:00

21 lines
235 B
C

#include <string.h>
#include <stdlib.h>
char *strdup(const char *s)
{
char *r = NULL;
char *p = NULL;
r = malloc(strlen(s) + 1);
if (!r)
return NULL;
for (p = r; *s != '\0'; s++, p++)
*p = *s;
*p = '\0';
return (r);
}