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

#include <h/mh.h>

char *
add (char *this, char *that)
{
    register char *cp;

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

    sprintf (cp, "%s%s", that, this);
    if (*that)
	free (that);
    return cp;
}
