]>
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.
13 /* concat returns a non-NULL malloc'd pointer to the catenation of the
14 * argument strings less their NUL terminators other than the last. The
15 * arguments are terminated by a NULL.
17 * Example: concat("abc", "def", "", "g", NULL) returns "abcdefg". */
19 concat (const char *s1
, ...)
25 len
= strlen (s1
) + 1;
27 while ((cp
= va_arg(list
, char *)))
31 dp
= sp
= mh_xmalloc(len
);
36 while ((cp
= va_arg (list
, char *)))