|
|
1.1 ! root 1: /* concat.c - concatenate a bunch of strings in managed memory */ ! 2: ! 3: #include "../h/mh.h" ! 4: #include <stdio.h> ! 5: #include <varargs.h> ! 6: ! 7: ! 8: /* VARARGS */ ! 9: ! 10: char *concat (va_alist) ! 11: va_dcl ! 12: { ! 13: register char *cp, ! 14: *dp, ! 15: *sp; ! 16: register unsigned len; ! 17: register va_list list; ! 18: ! 19: len = 1; ! 20: va_start (list); ! 21: while (cp = va_arg (list, char *)) ! 22: len += strlen (cp); ! 23: va_end (list); ! 24: ! 25: dp = sp = malloc (len); ! 26: if (dp == NULL) ! 27: adios (NULLCP, "unable to allocate string storage"); ! 28: ! 29: va_start (list); ! 30: while (cp = va_arg (list, char *)) ! 31: sp = copy (cp, sp); ! 32: va_end (list); ! 33: ! 34: return dp; ! 35: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.