summaryrefslogtreecommitdiff
path: root/lib/libc/string/strdup.c
blob: 1210bfdcd92fb49f7993f0a488ed57f0393495f8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
#include <stdlib.h>
#include <string.h>

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