1
0
mirror of https://frontier.innolan.net/rainlance/amiga-tz.git synced 2025-11-21 23:10:14 +00:00

added functions

SCCS-file: ialloc.c
SCCS-SID: 7.3
This commit is contained in:
Arthur David Olson
1985-10-23 09:48:28 -04:00
committed by Paul Eggert
parent 01b8495b97
commit ab0aef2ecc

View File

@ -12,24 +12,60 @@ static char sccsid[] = "%W%";
#define arg4alloc unsigned
#endif
#ifndef MAL
#define MAL 0
#endif
extern char * malloc();
extern char * calloc();
extern char * realloc();
extern char * strcat();
static E_oops()
{
wildrexit("allocating memory");
}
char * emalloc(size)
{
register char * ret;
if ((ret = malloc((arg4alloc) size)) == MAL || ret == NULL)
E_oops();
return ret;
}
char * ecalloc(nelem, elsize)
{
register char * ret;
if ((ret = calloc((arg4alloc) nelem, (arg4alloc) elsize)) == NULL)
E_oops();
return ret;
}
char * erealloc(ptr, size)
char * ptr;
{
register char * ret;
if ((ret = realloc(ptr, (arg4alloc) size)) == NULL)
E_oops();
return ret;
}
char * allocat(old, new)
char * old;
char * new;
{
register char * ret;
arg4alloc toalloc;
extern char * calloc();
extern char * realloc();
extern char * strcat();
register toalloc;
if (new == NULL)
new = "";
toalloc = strlen(new) + 1;
ret = (old == NULL) ? calloc(toalloc, sizeof *ret) :
realloc(old, (toalloc + strlen(old)) * sizeof *ret);
if (ret != NULL)
(void) strcat(ret, new);
return ret;
return (old == NULL) ? ecalloc(toalloc, sizeof *ret) :
erealloc(old, (toalloc + strlen(old)) * sizeof *ret);
}
char * allocpy(string)