summaryrefslogtreecommitdiff
path: root/src/tool_strdup.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/tool_strdup.c')
-rw-r--r--src/tool_strdup.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/tool_strdup.c b/src/tool_strdup.c
index a5725d6d4..ff80b56b9 100644
--- a/src/tool_strdup.c
+++ b/src/tool_strdup.c
@@ -22,6 +22,7 @@
*
***************************************************************************/
#include "tool_strdup.h"
+#include "memdebug.h" /* keep this as LAST include */
#ifndef HAVE_STRDUP
char *strdup(const char *str)
@@ -42,3 +43,14 @@ char *strdup(const char *str)
return newstr;
}
#endif
+
+char *memdup0(const char *data, size_t len)
+{
+ char *p = malloc(len + 1);
+ if(!p)
+ return NULL;
+ if(len)
+ memcpy(p, data, len);
+ p[len] = 0;
+ return p;
+}