15 lines
193 B
C
15 lines
193 B
C
#include <stdlib.h>
|
|
#include <string.h>
|
|
|
|
char *strdup(char *s)
|
|
{
|
|
size_t len = strlen(s);
|
|
char *out = malloc(len + 1);
|
|
if (!out) {
|
|
return NULL;
|
|
}
|
|
|
|
memcpy(out, s, len + 1);
|
|
return out;
|
|
}
|