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