summaryrefslogtreecommitdiffstats
path: root/usr/klibc/strdup.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr/klibc/strdup.c')
-rw-r--r--usr/klibc/strdup.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/usr/klibc/strdup.c b/usr/klibc/strdup.c
new file mode 100644
index 0000000..905b51d
--- /dev/null
+++ b/usr/klibc/strdup.c
@@ -0,0 +1,17 @@
+/*
+ * strdup.c
+ */
+
+#include <string.h>
+#include <stdlib.h>
+
+char *strdup(const char *s)
+{
+ int l = strlen(s) + 1;
+ char *d = malloc(l);
+
+ if (d)
+ memcpy(d, s, l);
+
+ return d;
+}