From 7f1ad7a40e7ac03b9a760c27fff4ad74d5fcc20f Mon Sep 17 00:00:00 2001 From: Wayne Davison Date: Mon, 18 Oct 2004 19:13:57 +0000 Subject: Added bicat() that works like dyncat(), but uses permanent memory instead of the heap. --- Src/string.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'Src/string.c') diff --git a/Src/string.c b/Src/string.c index a0fc2ee8c..397c868ce 100644 --- a/Src/string.c +++ b/Src/string.c @@ -103,6 +103,22 @@ dyncat(char *s1, char *s2) return ptr; } +/**/ +mod_export char * +bicat(const char *s1, const char *s2) +{ + /* This version always uses permanently-allocated space. */ + char *ptr; + size_t l1 = strlen(s1); + + ptr = (char *)zalloc(l1 + strlen(s2) + 1); + strcpy(ptr, s1); + strcpy(ptr + l1, s2); + return ptr; +} + +/* like strdup(), but with a specified length */ + /**/ mod_export char * dupstrpfx(const char *s, int len) @@ -118,6 +134,7 @@ dupstrpfx(const char *s, int len) mod_export char * ztrduppfx(const char *s, int len) { + /* This version always uses permanently-allocated space. */ char *r = zalloc(len + 1); memcpy(r, s, len); -- cgit 1.4.1