3 static char elsieid
[] = "@(#)ialloc.c 8.29";
4 #endif /* !defined NOID */
5 #endif /* !defined lint */
9 * $FreeBSD: src/usr.sbin/zic/ialloc.c,v 1.5 1999/08/28 01:21:18 peter Exp $
10 * $DragonFly: src/usr.sbin/zic/ialloc.c,v 1.4 2004/12/18 22:48:15 swildner Exp $
16 #define nonzero(n) (((n) == 0) ? 1 : (n))
21 return malloc((size_t) nonzero(n
));
25 icalloc(int nelem
, int elsize
)
27 if (nelem
== 0 || elsize
== 0)
29 return calloc((size_t) nelem
, (size_t) elsize
);
33 irealloc(void *const pointer
, const int size
)
37 return realloc((void *) pointer
, (size_t) nonzero(size
));
41 icatalloc(char *const old
, const char *new)
46 newsize
= (new == NULL
) ? 0 : strlen(new);
49 else if (newsize
== 0)
51 else oldsize
= strlen(old
);
52 if ((result
= irealloc(old
, oldsize
+ newsize
+ 1)) != NULL
)
54 strcpy(result
+ oldsize
, new);
59 icpyalloc(const char *string
)
61 return icatalloc((char *) NULL
, string
);
72 icfree(char * const p
)