doc
|
Macros | |
#define | ARRAY_SIZE(a) (sizeof(a)/sizeof(a[0])) |
#define | discard_const(ptr) ((void *)((uintptr_t)(ptr))) |
#define | discard_const_p(type, ptr) ((type *)discard_const(ptr)) |
#define | INT_TO_POINTER(i) (void *) i |
#define | likely(x) (x) |
#define | MAX(a, b) ((a) < (b) ? (b) : (a)) |
#define | MIN(a, b) ((a) < (b) ? (a) : (b)) |
#define | POINTER_TO_INT(p) *((int *) (p)) |
#define | SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0) |
#define | unlikely(x) (x) |
#define | ZERO_STRUCT(x) memset((char *)&(x), 0, sizeof(x)) |
#define | ZERO_STRUCTP(x) do { if ((x) != NULL) memset((char *)(x), 0, sizeof(*(x))); } while(0) |
#define ARRAY_SIZE | ( | a | ) | (sizeof(a)/sizeof(a[0])) |
#define discard_const | ( | ptr | ) | ((void *)((uintptr_t)(ptr))) |
This is a hack to fix warnings.
The idea is to use this everywhere that we get the "discarding const" warning by the compiler. That doesn't actually fix the real issue, but marks the place and you can search the code for discard_const.
Please use this macro only when there is no other way to fix the warning. We should use this function in only in a very few places.
Also, please call this via the discard_const_p() macro interface, as that makes the return type safe.
#define discard_const_p | ( | type, | |
ptr | |||
) | ((type *)discard_const(ptr)) |
#define MAX | ( | a, | |
b | |||
) | ((a) < (b) ? (b) : (a)) |
#define MIN | ( | a, | |
b | |||
) | ((a) < (b) ? (a) : (b)) |
#define SAFE_FREE | ( | x | ) | do { if ((x) != NULL) {free(x); x=NULL;} } while(0) |
#define ZERO_STRUCT | ( | x | ) | memset((char *)&(x), 0, sizeof(x)) |