Download

Support

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 (  )     (sizeof(x) / sizeof(*(x)))

The count of a static array

#define FREE ( dat   ) 

Value:

do { \
        free(dat); dat = NULL; \
} while (0)
Free the data pointed to by dat and it to NULL.

#define IF_FREE ( dat   ) 

Value:

do { \
        if (dat) FREE(dat); \
} while (0)
If dat is non-NULL, free dat and assign it to NULL.

#define IF_FREE_HASH ( hash   ) 

Value:

do { \
        if (hash) { \
                ecore_hash_destroy(hash); \
                hash = NULL; \
        } \
} while (0)
If hash is non-NULL, free hash and set it NULL.

#define IF_FREE_LIST ( list   ) 

Value:

do { \
        if (list) { \
                ecore_list_destroy(list); \
                list = NULL; \
        } \
} while (0)
If list is non-NULL, free list and set it NULL.

#define IF_RELEASE ( item   ) 

Value:

do { \
        if (item) { \
                ecore_string_release(item); \
                item = NULL; \
        } \
} while (0)
If item is non-NULL, ecore_string_release item and set it NULL.

#define INT_TO_INTPTR (  )     ((void *)((long int)(x)))

Does a cast from the type int to an pointer

#define INTPTR_TO_INT (  )     ((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,
 )     (((x) > (y)) ? (x) : (y))

Select the maximum of two values

#define MIN ( x,
 )     (((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 (  )     ((void *)((unsigned long int)(x)))

Does a cast from the type int to an pointer

#define UINTPTR_TO_UINT (  )     ((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.


Copyright © Enlightenment.org

Enlightened Widget Library Documentation Generated: Sun Sep 27 01:49:47 2009