]>
diplodocus.org Git - nmh/blob - sbr/concat.c
1 /* concat.c -- concatenate a variable number (minimum of 1)
2 * of strings in managed memory
4 * This code is Copyright (c) 2002, by the authors of nmh. See the
5 * COPYRIGHT file in the root directory of the nmh distribution for
6 * complete copyright information.
14 /* concat returns a non-NULL malloc'd pointer to the catenation of the
15 * argument strings less their NUL terminators other than the last. The
16 * arguments are terminated by a NULL.
18 * Example: concat("abc", "def", "", "g", NULL) returns "abcdefg". */
20 concat (const char *s1
, ...)
26 len
= strlen (s1
) + 1;
28 while ((cp
= va_arg(list
, char *)))
32 dp
= sp
= mh_xmalloc(len
);
37 while ((cp
= va_arg (list
, char *)))