u/misc: Improve docs of calloc macros.

This commit is contained in:
Ryan Pavlik 2020-08-26 11:26:46 -05:00
parent cb26f7255c
commit 9d19ab2755

View file

@ -24,6 +24,14 @@ extern "C" {
* Use instead of a bare calloc, but only when U_TYPED_CALLOC and
* U_TYPED_ARRAY_CALLOC do not meet your needs.
*
* - If you are using `U_CALLOC_WITH_CAST(struct MyStruct, sizeof(MyStruct))` to
* allocate a single structure of fixed size, you should actually use
* `U_TYPED_CALLOC(struct MyStruct)`.
*
* - If you are using `U_CALLOC_WITH_CAST(struct MyStruct, sizeof(MyStruct) *
* n)` to allocate an array, you should actually use
* `U_TYPED_ARRAY_CALLOC(struct MyStruct, n)`.
*
* @ingroup aux_util
*/
#define U_CALLOC_WITH_CAST(TYPE, SIZE) ((TYPE *)calloc(1, SIZE))