aux/util: Add U_TYPED_CALLOC macro to wrap calloc and casting.

This commit is contained in:
Ryan Pavlik 2019-03-21 15:18:44 -05:00
parent 142a9a77eb
commit e57e858351

View file

@ -12,6 +12,18 @@
extern "C" {
#endif
/*!
* Allocate and zero the space required for some type, and cast the return type
* appropriately.
*/
#define U_TYPED_CALLOC(TYPE) ((TYPE *)calloc(1, sizeof(TYPE)))
/*!
* Allocate and zero the space required for some type, and cast the return type
* appropriately.
*/
#define U_TYPED_ARRAY_CALLOC(TYPE, COUNT) \
((TYPE *)calloc((COUNT), sizeof(TYPE)))
#ifdef __cplusplus