
/*
 * add.c -- concatenate two strings in managed memory
 *
 * $Id$
 */

#include <h/mh.h>

char *
add (char *s1, char *s2)
{
    char *cp;

    if (!s1)
	s1 = "";
    if (!s2)
	s2 = "";
    if (!(cp = malloc ((size_t) (strlen (s1) + strlen (s2) + 1))))
	adios (NULL, "unable to allocate string storage");

    sprintf (cp, "%s%s", s2, s1);
    if (*s2)
	free (s2);
    return cp;
}
