doc
Macros
cynapses libc macro definitions
cynapses libc API (internal)

Macros

#define ARRAY_SIZE(a)   (sizeof(a)/sizeof(a[0]))
#define INT_TO_POINTER(i)   (void *) i
#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((void*)x); x=NULL;} } while(0)
#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)

Detailed Description


Macro Definition Documentation

#define ARRAY_SIZE (   a)    (sizeof(a)/sizeof(a[0]))

Get the size of an array.

Definition at line 55 of file c_macro.h.

#define INT_TO_POINTER (   i)    (void *) i

Definition at line 36 of file c_macro.h.

#define MAX (   a,
 
)    ((a) < (b) ? (b) : (a))

Get the bigger value.

Definition at line 52 of file c_macro.h.

#define MIN (   a,
 
)    ((a) < (b) ? (a) : (b))

Get the smaller value.

Definition at line 49 of file c_macro.h.

#define POINTER_TO_INT (   p)    *((int *) (p))

Definition at line 37 of file c_macro.h.

#define SAFE_FREE (   x)    do { if ((x) != NULL) {free((void*)x); x=NULL;} } while(0)

Free memory and zero the pointer.

Definition at line 46 of file c_macro.h.

#define ZERO_STRUCT (   x)    memset((char *)&(x), 0, sizeof(x))

Zero a structure.

Definition at line 40 of file c_macro.h.

#define ZERO_STRUCTP (   x)    do { if ((x) != NULL) memset((char *)(x), 0, sizeof(*(x))); } while(0)

Zero a structure given a pointer to the structure.

Definition at line 43 of file c_macro.h.