Mercurial > hg > Applications > mh
view sbr/concat.c @ 12:441a2190cfae
Lion fix
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Sat, 21 Apr 2012 13:10:49 +0900 |
parents | f89a9a79e124 |
children |
line wrap: on
line source
/* concat.c - concatenate a bunch of strings in managed memory */ #include "../h/mh.h" #include <stdio.h> #include <stdarg.h> /* VARARGS */ char *concat (char *first, ...) { register char *cp, *dp, *sp; register unsigned len; va_list list; len = 1; va_start (list, first); len += strlen (first); 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, first); sp = copy (first, sp); while (cp = va_arg (list, char *)) sp = copy (cp, sp); va_end (list); return dp; }