Ewl_Macros: Useful Macros Used Internally and Available Externally
Detailed Description
Defines a variety of utility macros.
Defines | |
#define | ARRAY_COUNT(x) (sizeof(x) / sizeof(*(x))) |
#define | FREE(dat) |
#define | IF_FREE(dat) |
#define | IF_FREE_HASH(hash) |
#define | IF_FREE_LIST(list) |
#define | IF_RELEASE(item) |
#define | INT_TO_INTPTR(x) ((void *)((long int)(x))) |
#define | INTPTR_TO_INT(x) ((int)((long int)(x))) |
#define | MAX(x, y) (((x) > (y)) ? (x) : (y)) |
#define | MIN(x, y) (((x) > (y)) ? (y) : (x)) |
#define | NEW(type, num) calloc(num, sizeof(type)) |
#define | REALLOC(dat, type, num) dat = realloc(dat, sizeof(type) * (num)) |
#define | UINT_TO_UINTPTR(x) ((void *)((unsigned long int)(x))) |
#define | UINTPTR_TO_UINT(x) ((unsigned int)((unsigned long int)(x))) |
#define | ZERO(ptr, type, num) ptr = memset(ptr, 0, sizeof(type) * (num)) |
Define Documentation
#define ARRAY_COUNT | ( | x | ) | (sizeof(x) / sizeof(*(x))) |
The count of a static array
#define FREE | ( | dat | ) |
Value:
do { \ free(dat); dat = NULL; \ } while (0)
#define IF_FREE | ( | dat | ) |
Value:
do { \ if (dat) FREE(dat); \ } while (0)
#define IF_FREE_HASH | ( | hash | ) |
Value:
do { \ if (hash) { \ ecore_hash_destroy(hash); \ hash = NULL; \ } \ } while (0)
#define IF_FREE_LIST | ( | list | ) |
Value:
do { \ if (list) { \ ecore_list_destroy(list); \ list = NULL; \ } \ } while (0)
#define IF_RELEASE | ( | item | ) |
Value:
do { \ if (item) { \ ecore_string_release(item); \ item = NULL; \ } \ } while (0)
#define INT_TO_INTPTR | ( | x | ) | ((void *)((long int)(x))) |
Does a cast from the type int to an pointer
#define INTPTR_TO_INT | ( | x | ) | ((int)((long int)(x))) |
Does a cast from a pointer to the type int, if debug is enabled at compile-time it will add a runtime check if any information get lost.
#define MAX | ( | x, | |||
y | ) | (((x) > (y)) ? (x) : (y)) |
Select the maximum of two values
#define MIN | ( | x, | |||
y | ) | (((x) > (y)) ? (y) : (x)) |
Select the minimum of two values
#define NEW | ( | type, | |||
num | ) | calloc(num, sizeof(type)) |
Allocates memory of num elements of sizeof(type).
#define REALLOC | ( | dat, | |||
type, | |||||
num | ) | dat = realloc(dat, sizeof(type) * (num)) |
Reallocates memory pointed to by dat to num elements of sizeof(type).
#define UINT_TO_UINTPTR | ( | x | ) | ((void *)((unsigned long int)(x))) |
Does a cast from the type int to an pointer
#define UINTPTR_TO_UINT | ( | x | ) | ((unsigned int)((unsigned long int)(x))) |
Does a cast from a pointer to the type unsigned int, if debug is enabled at compile-time it will add a runtime check if any information get lost.
#define ZERO | ( | ptr, | |||
type, | |||||
num | ) | ptr = memset(ptr, 0, sizeof(type) * (num)) |
Set the first num elements of sizeof(type) pointed to by ptr to zero.