|
|
1.1 ! root 1: /* add.c - concatenate two strings in managed memory */ ! 2: ! 3: #include "../h/mh.h" ! 4: #include <stdio.h> ! 5: ! 6: ! 7: char *add (this, that) ! 8: register char *this, ! 9: *that; ! 10: { ! 11: register char *cp; ! 12: ! 13: if (!this) ! 14: this = ""; ! 15: if (!that) ! 16: that = ""; ! 17: if ((cp = malloc ((unsigned) (strlen (this) + strlen (that) + 1))) == NULL) ! 18: adios (NULLCP, "unable to allocate string storage"); ! 19: ! 20: (void) sprintf (cp, "%s%s", that, this); ! 21: if (*that) ! 22: free (that); ! 23: return cp; ! 24: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.