summary refs log tree commit diff
path: root/Src/string.c
diff options
context:
space:
mode:
authorWayne Davison <wayned@users.sourceforge.net>2004-10-18 19:13:57 +0000
committerWayne Davison <wayned@users.sourceforge.net>2004-10-18 19:13:57 +0000
commit7f1ad7a40e7ac03b9a760c27fff4ad74d5fcc20f (patch)
tree4b1c3daec5b6501f2e6712c7a180878585a3bf6f /Src/string.c
parent8901caa58f133b40f92f819861fbaf4c797a518f (diff)
downloadzsh-7f1ad7a40e7ac03b9a760c27fff4ad74d5fcc20f.tar.gz
zsh-7f1ad7a40e7ac03b9a760c27fff4ad74d5fcc20f.tar.xz
zsh-7f1ad7a40e7ac03b9a760c27fff4ad74d5fcc20f.zip
Added bicat() that works like dyncat(), but uses permanent memory
instead of the heap.
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 a0fc2ee8c..397c868ce 100644
--- a/Src/string.c
+++ b/Src/string.c
@@ -105,6 +105,22 @@ dyncat(char *s1, char *s2)
 
 /**/
 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)
 {
     char *r = zhalloc(len + 1);
@@ -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);