forked from cosmonaut/wraith-lang
16 lines
227 B
C
16 lines
227 B
C
|
#include "util.h"
|
||
|
|
||
|
#include <string.h>
|
||
|
|
||
|
char* strdup (const char* s)
|
||
|
{
|
||
|
size_t slen = strlen(s);
|
||
|
char* result = malloc(slen + 1);
|
||
|
if(result == NULL)
|
||
|
{
|
||
|
return NULL;
|
||
|
}
|
||
|
|
||
|
memcpy(result, s, slen+1);
|
||
|
return result;
|
||
|
}
|