diff src/c/urweb.c @ 922:d6a71f19a3d8

Find chances to use mstrcat()
author Adam Chlipala <adamc@hcoop.net>
date Wed, 09 Sep 2009 08:15:46 -0400
parents ae0110465421
children 552c989c1601
line wrap: on
line diff
--- a/src/c/urweb.c	Wed Sep 09 08:00:45 2009 -0400
+++ b/src/c/urweb.c	Wed Sep 09 08:15:46 2009 -0400
@@ -2836,3 +2836,23 @@
   return r;
 }
 
+uw_Basis_string uw_Basis_mstrcat(uw_context ctx, ...) {
+  va_list ap;
+  size_t len = 1;
+  char *s, *r, *s2;
+  
+  va_start(ap, ctx);
+  for (s = va_arg(ap, char*); s; s = va_arg(ap, char*))
+    len += strlen(s);
+  va_end(ap);
+
+  r = uw_malloc(ctx, len);
+  va_start(ap, ctx);
+  for (s2 = r, s = va_arg(ap, char*); s; s = va_arg(ap, char*))
+    while (*s)
+      *s2++ = *s++;
+  va_end(ap);
+  *s2 = 0;
+
+  return r;
+}