File:  [CSRG BSD Unix] / 43BSD / contrib / mh / sbr / concat.c
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Tue Apr 24 16:12:54 2018 UTC (8 years, 1 month ago) by root
Branches: MAIN, BSD
CVS tags: HEAD, BSD43
BSD 4.3

/* concat.c - concatenate a bunch of strings in managed memory */

#include "../h/mh.h"
#include <stdio.h>
#include <varargs.h>


/* VARARGS */

char   *concat (va_alist)
va_dcl
{
    register char  *cp,
                   *dp,
                   *sp;
    register unsigned   len;
    register    va_list list;

    len = 1;
    va_start (list); 
    while (cp = va_arg (list, char *))
	len += strlen (cp);
    va_end (list);

    dp = sp = malloc (len);
    if (dp == NULL)
	adios (NULLCP, "unable to allocate string storage");

    va_start (list); 
    while (cp = va_arg (list, char *))
	sp = copy (cp, sp);
    va_end (list);

    return dp;
}

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.