source: trunk/third/nmh/sbr/concat.c @ 12455

Revision 12455, 650 bytes checked in by danw, 26 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r12454, which included commits to RCS files with non-trunk default branches.
Line 
1
2/*
3 * concat.c -- concatenate a variable number (minimum of 1)
4 *             of strings in managed memory
5 *
6 * $Id: concat.c,v 1.1.1.1 1999-02-07 18:14:07 danw Exp $
7 */
8
9#include <h/mh.h>
10
11
12char *
13concat (char *s1, ...)
14{
15    char *cp, *dp, *sp;
16    size_t len;
17    va_list list;
18
19    len = strlen (s1) + 1;
20    va_start(list, s1);
21    while ((cp = va_arg(list, char *)))
22        len += strlen (cp);
23    va_end(list);
24
25    if (!(dp = sp = malloc(len)))
26        adios (NULL, "unable to allocate string storage");
27
28    sp = copy(s1, sp);
29
30    va_start(list, s1);
31    while ((cp = va_arg (list, char *)))
32        sp = copy(cp, sp);
33    va_end(list);
34
35    return dp;
36}
Note: See TracBrowser for help on using the repository browser.