2019-03-18 05:52:32 +00:00
|
|
|
// Copyright 2019, Collabora, Ltd.
|
|
|
|
// SPDX-License-Identifier: BSL-1.0
|
|
|
|
/*!
|
|
|
|
* @file
|
|
|
|
* @brief Very small misc utils.
|
|
|
|
* @author Jakob Bornecrantz <jakob@collabora.com>
|
2019-04-06 11:28:56 +00:00
|
|
|
* @ingroup aux_util
|
2019-03-18 05:52:32 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2019-04-03 16:57:05 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
|
2019-03-18 05:52:32 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2019-04-10 11:33:28 +00:00
|
|
|
|
|
|
|
/*!
|
|
|
|
* Allocate and zero the give size and casts the memory into a pointer of the
|
|
|
|
* given type.
|
|
|
|
*
|
|
|
|
* @ingroup aux_util
|
|
|
|
*/
|
|
|
|
#define U_CALLOC_WITH_CAST(TYPE, SIZE) ((TYPE *)calloc(1, SIZE))
|
|
|
|
|
2019-03-21 20:18:44 +00:00
|
|
|
/*!
|
|
|
|
* Allocate and zero the space required for some type, and cast the return type
|
|
|
|
* appropriately.
|
2019-04-06 11:28:56 +00:00
|
|
|
*
|
|
|
|
* @ingroup aux_util
|
2019-03-21 20:18:44 +00:00
|
|
|
*/
|
|
|
|
#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.
|
2019-04-06 11:28:56 +00:00
|
|
|
*
|
|
|
|
* @ingroup aux_util
|
2019-03-21 20:18:44 +00:00
|
|
|
*/
|
|
|
|
#define U_TYPED_ARRAY_CALLOC(TYPE, COUNT) \
|
|
|
|
((TYPE *)calloc((COUNT), sizeof(TYPE)))
|
2019-03-18 05:52:32 +00:00
|
|
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|