From 0b44a0315b47dd8eced9f3b7f31580cf14bbfc01 Mon Sep 17 00:00:00 2001 From: Rich Felker Date: Sat, 12 Feb 2011 00:22:29 -0500 Subject: initial check-in, version 0.5.0 --- src/string/strdup.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 src/string/strdup.c (limited to 'src/string/strdup.c') diff --git a/src/string/strdup.c b/src/string/strdup.c new file mode 100644 index 00000000..dd5f80c1 --- /dev/null +++ b/src/string/strdup.c @@ -0,0 +1,13 @@ +#include +#include +#include "libc.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); +} + +weak_alias(__strdup, strdup); -- cgit v1.2.1