wraith-lang/src/util.c

18 lines
276 B
C
Raw Normal View History

2021-05-07 00:15:17 +00:00
#include "util.h"
2021-05-16 07:42:37 +00:00
#include <stdlib.h>
2021-05-07 00:15:17 +00:00
#include <string.h>
2021-05-16 07:42:37 +00:00
char *strdup(const char *s)
2021-05-07 00:15:17 +00:00
{
2021-05-16 07:42:37 +00:00
size_t slen = strlen(s);
char *result = (char *)malloc(slen + 1);
if (result == NULL)
{
return NULL;
}
2021-05-07 00:15:17 +00:00
2021-05-16 07:42:37 +00:00
memcpy(result, s, slen + 1);
return result;
}