2 ** This file is in the public domain, so clarified as of
3 ** 2006-07-17 by Arthur David Olson.
8 static char elsieid
[] = "@(#)ialloc.c 8.30";
9 #endif /* !defined NOID */
10 #endif /* !defined lint */
16 #define nonzero(n) (((n) == 0) ? 1 : (n))
22 return malloc((size_t) nonzero(n
));
26 icalloc(nelem
, elsize
)
30 if (nelem
== 0 || elsize
== 0)
32 return calloc((size_t) nelem
, (size_t) elsize
);
36 irealloc(pointer
, size
)
42 return realloc((void *) pointer
, (size_t) nonzero(size
));
48 const char * const new;
50 register char * result
;
51 register int oldsize
, newsize
;
53 newsize
= (new == NULL
) ? 0 : strlen(new);
56 else if (newsize
== 0)
58 else oldsize
= strlen(old
);
59 if ((result
= irealloc(old
, oldsize
+ newsize
+ 1)) != NULL
)
61 (void) strcpy(result
+ oldsize
, new);
67 const char * const string
;
69 return icatalloc((char *) NULL
, string
);