diff options
Diffstat (limited to 'Src/string.c')
-rw-r--r-- | Src/string.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/Src/string.c b/Src/string.c index 04e7446c9..9e14ef949 100644 --- a/Src/string.c +++ b/Src/string.c @@ -41,6 +41,37 @@ dupstring(const char *s) return t; } +/* Duplicate string on heap when length is known */ + +/**/ +mod_export char * +dupstring_wlen(const char *s, unsigned len) +{ + char *t; + + if (!s) + return NULL; + t = (char *) zhalloc(len + 1); + memcpy(t, s, len); + t[len] = '\0'; + 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) |