aboutsummaryrefslogtreecommitdiffstats
path: root/memory/strdup.c
diff options
context:
space:
mode:
Diffstat (limited to 'memory/strdup.c')
-rw-r--r--memory/strdup.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/memory/strdup.c b/memory/strdup.c
new file mode 100644
index 0000000..a69143d
--- /dev/null
+++ b/memory/strdup.c
@@ -0,0 +1,10 @@
+#include "memory.h"
+
+char *strdup(char const *restrict string)
+{
+ size_t lenght = strlen(string) + 1;
+ char *duplicate = reallocarray(NULL, lenght, sizeof *duplicate);
+ if (duplicate != NULL)
+ memcpy(duplicate, string, lenght);
+ return duplicate;
+}