Monado OpenXR Runtime
u_misc.h File Reference

Very small misc utils. More...

#include <stdlib.h>
#include <string.h>
Include dependency graph for u_misc.h:

Go to the source code of this file.

Macros

#define U_CALLOC_WITH_CAST(TYPE, SIZE)   ((TYPE *)calloc(1, SIZE))
 Allocate and zero the give size and casts the memory into a pointer of the given type. More...
 
#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. More...
 
#define U_TYPED_ARRAY_CALLOC(TYPE, COUNT)   ((TYPE *)calloc((COUNT), sizeof(TYPE)))
 Allocate and zero the space required for some type, and cast the return type appropriately. More...
 
#define U_ZERO(PTR)   memset((PTR), 0, sizeof(*(PTR)))
 Zeroes the correct amount of memory based on the type pointed-to by the argument. More...
 
#define U_ZERO_ARRAY(ARRAY)   memset((ARRAY), 0, sizeof(ARRAY))
 Zeroes the correct amount of memory based on the type and size of the static array named in the argument. More...
 
#define U_ARRAY_REALLOC_OR_FREE(VAR, TYPE, COUNT)   (VAR) = ((TYPE *)u_realloc_or_free((VAR), sizeof(TYPE) * (COUNT)))
 Re-allocate the space required for some type, and update the pointer - freeing the allocation instead if it can't be resized. More...
 

Functions

static void * u_realloc_or_free (void *ptr, size_t new_size)
 Reallocates or frees dynamically-allocated memory. More...
 

Detailed Description

Very small misc utils.

Author
Jakob Bornecrantz jakob.nosp@m.@col.nosp@m.labor.nosp@m.a.co.nosp@m.m