aboutsummaryrefslogtreecommitdiff
path: root/src/string/strdup.c
blob: afc85a6f7d94ec39b25cec0f27b68316bdd87b0a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include <stdlib.h>
#include <string.h>

char *strdup(const char *s)
{
	size_t l = strlen(s);
	char *d = malloc(l+1);
	if (!d) return NULL;
	return memcpy(d, s, l+1);
}


#ifdef TEST
int
main(void) {
	return 0;
}
#endif