1
0
mirror of https://frontier.innolan.net/rainlance/amiga-tz.git synced 2026-05-07 06:18:51 +00:00

optimized

SCCS-file: ialloc.c
SCCS-SID: 7.4
This commit is contained in:
Arthur David Olson
1985-10-23 19:15:05 -04:00
committed by Paul Eggert
parent ab0aef2ecc
commit 77c0fda34b

View File

@@ -12,14 +12,10 @@ 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();
extern char * strcpy();
static E_oops()
{
@@ -30,8 +26,12 @@ char * emalloc(size)
{
register char * ret;
if ((ret = malloc((arg4alloc) size)) == MAL || ret == NULL)
if ((ret = malloc((arg4alloc) size)) == NULL)
E_oops();
#ifdef MAL
if (ret == MAL)
E_oops();
#endif
return ret;
}
@@ -59,13 +59,20 @@ char * old;
char * new;
{
register char * ret;
register toalloc;
register oldsize, newsize;
if (new == NULL)
new = "";
toalloc = strlen(new) + 1;
return (old == NULL) ? ecalloc(toalloc, sizeof *ret) :
erealloc(old, (toalloc + strlen(old)) * sizeof *ret);
newsize = strlen(new);
if (old == NULL) {
oldsize = 0;
ret = ecalloc(newsize + 1, sizeof *ret);
} else {
oldsize = strlen(old);
ret = erealloc(old, (oldsize + newsize + 1) * sizeof *ret);
}
(void) strcpy(ret + oldsize, new);
return ret;
}
char * allocpy(string)