Files
amiga-tz/ialloc.c
T

33 lines
621 B
C
Raw Normal View History

2006-07-17 10:43:01 -04:00
/*
** This file is in the public domain, so clarified as of
** 2006-07-17 by Arthur David Olson.
*/
1988-02-17 22:22:32 -05:00
/*LINTLIBRARY*/
1992-11-23 11:25:20 -05:00
#include "private.h"
1988-02-18 11:33:47 -05:00
1992-11-23 11:25:20 -05:00
char *
2012-10-12 07:53:12 -07:00
icatalloc(char *const old, const char *const new)
1992-11-23 11:25:20 -05:00
{
2012-10-26 17:37:42 -07:00
register char * result;
register int oldsize, newsize;
1992-11-23 11:25:20 -05:00
1995-01-06 17:55:30 -05:00
newsize = (new == NULL) ? 0 : strlen(new);
if (old == NULL)
1992-11-23 11:25:20 -05:00
oldsize = 0;
else if (newsize == 0)
return old;
else oldsize = strlen(old);
2012-10-12 07:53:12 -07:00
if ((result = realloc(old, oldsize + newsize + 1)) != NULL)
1995-01-06 17:55:30 -05:00
if (new != NULL)
1992-11-23 11:25:20 -05:00
(void) strcpy(result + oldsize, new);
return result;
}
char *
2012-10-12 07:53:12 -07:00
icpyalloc(const char *const string)
1992-11-23 11:25:20 -05:00
{
2012-10-12 07:53:12 -07:00
return icatalloc(NULL, string);
1987-03-29 17:55:10 -05:00
}