2 ** This file is in the public domain, so clarified as of
3 ** 2006-07-17 by Arthur David Olson.
8 * $FreeBSD: src/usr.sbin/zic/ialloc.c,v 1.5 1999/08/28 01:21:18 peter Exp $
9 * $DragonFly: src/usr.sbin/zic/ialloc.c,v 1.5 2008/10/19 20:15:58 swildner Exp $
15 #define nonzero(n) (((n) == 0) ? 1 : (n))
20 return malloc((size_t) nonzero(n
));
24 icalloc(int nelem
, int elsize
)
26 if (nelem
== 0 || elsize
== 0)
28 return calloc((size_t) nelem
, (size_t) elsize
);
32 irealloc(void *const pointer
, const int size
)
36 return realloc((void *) pointer
, (size_t) nonzero(size
));
40 icatalloc(char *const old
, const char *new)
45 newsize
= (new == NULL
) ? 0 : strlen(new);
48 else if (newsize
== 0)
50 else oldsize
= strlen(old
);
51 if ((result
= irealloc(old
, oldsize
+ newsize
+ 1)) != NULL
)
53 strcpy(result
+ oldsize
, new);
58 icpyalloc(const char *string
)
60 return icatalloc(NULL
, string
);
71 icfree(char * const p
)