2 ** This file is in the public domain, so clarified as of
3 ** 2006-07-17 by Arthur David Olson.
7 * $FreeBSD: src/usr.sbin/zic/ialloc.c,v 1.5 1999/08/28 01:21:18 peter Exp $
13 #define nonzero(n) (((n) == 0) ? 1 : (n))
18 return malloc((size_t) nonzero(n));
22 icalloc(int nelem, int elsize)
24 if (nelem == 0 || elsize == 0)
26 return calloc((size_t) nelem, (size_t) elsize);
30 irealloc(void *const pointer, const int size)
34 return realloc((void *) pointer, (size_t) nonzero(size));
38 icatalloc(char *const old, const char *new)
43 newsize = (new == NULL) ? 0 : strlen(new);
46 else if (newsize == 0)
48 else oldsize = strlen(old);
49 if ((result = irealloc(old, oldsize + newsize + 1)) != NULL)
51 strcpy(result + oldsize, new);
56 icpyalloc(const char *string)
58 return icatalloc(NULL, string);
69 icfree(char * const p)