2 * UCW Library -- Memory Pools (String Operations)
4 * (c) 2004 Martin Mares <mj@ucw.cz>
6 * This software may be freely distributed and used according to the terms
7 * of the GNU Lesser General Public License.
11 #include "lib/mempool.h"
17 mp_strdup(struct mempool *p, char *s)
19 uns l = strlen(s) + 1;
20 char *t = mp_alloc_fast_noalign(p, l);
26 mp_multicat(struct mempool *p, ...)
33 while (x = va_arg(a, char *))
35 uns *sizes = alloca(cnt * sizeof(uns));
40 while (x = va_arg(a, char *))
41 len += sizes[cnt++] = strlen(x);
42 char *buf = mp_alloc_fast_noalign(p, len);
46 while (x = va_arg(args, char *))
48 memcpy(y, x, sizes[cnt]);
62 struct mempool *p = mp_new(64);
63 char *s = mp_strdup(p, "12345");
64 char *c = mp_multicat(p, "<<", s, ">>", NULL);