view sbr/add.c @ 10:a6481689f99c

*** empty log message ***
author kono
date Wed, 06 Dec 2006 03:17:53 +0900
parents bce86c4163a3
children
line wrap: on
line source

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

#include "../h/mh.h"
#include <stdio.h>


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

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

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