view sbr/getcpy.c @ 17:76d91e545ea8 default tip

addrsbr and dtimep fix
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 24 Nov 2014 14:49:25 +0900
parents bce86c4163a3
children
line wrap: on
line source

/* getcpy.c - copy a string in managed memory */

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


char   *getcpy (str)
register char  *str;
{
    register char  *cp;

    if (!str) {
	if ((cp = malloc ((unsigned) (1))) == NULL)
	    adios (NULLCP, "unable to allocate string storage");
	(void) strcpy (cp, "");
    } else {
	if ((cp = malloc ((unsigned) (strlen (str) + 1))) == NULL)
	    adios (NULLCP, "unable to allocate string storage");

	(void) strcpy (cp, str);
    }
    return cp;
}