monado/src/xrt/auxiliary/util/u_misc.h

39 lines
746 B
C
Raw Normal View History

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>
* @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
/*!
* Allocate and zero the space required for some type, and cast the return type
* appropriately.
*
* @ingroup aux_util
*/
#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.
*
* @ingroup aux_util
*/
#define U_TYPED_ARRAY_CALLOC(TYPE, COUNT) \
((TYPE *)calloc((COUNT), sizeof(TYPE)))
2019-03-18 05:52:32 +00:00
#ifdef __cplusplus
}
#endif