about summary refs log tree commit diff
path: root/Src/string.c
diff options
context:
space:
mode:
Diffstat (limited to 'Src/string.c')
-rw-r--r--Src/string.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/Src/string.c b/Src/string.c
index b46ea60cf..a8da14fe0 100644
--- a/Src/string.c
+++ b/Src/string.c
@@ -41,6 +41,8 @@ dupstring(const char *s)
     return t;
 }
 
+/* Duplicate string on heap when length is known */
+
 /**/
 mod_export char *
 dupstring_wlen(const char *s, unsigned len)
@@ -54,6 +56,21 @@ dupstring_wlen(const char *s, unsigned len)
     return t;
 }
 
+/* Duplicate string on heap, returning length of string */
+
+/**/
+mod_export char *
+dupstring_glen(const char *s, unsigned *len_ret)
+{
+    char *t;
+
+    if (!s)
+	return NULL;
+    t = (char *) zhalloc((*len_ret = strlen((char *)s)) + 1);
+    strcpy(t, s);
+    return t;
+}
+
 /**/
 mod_export char *
 ztrdup(const char *s)