lib/ewl_macros.h
Go to the documentation of this file.00001
00002 #ifndef EWL_MACROS_H
00003 #define EWL_MACROS_H
00004
00012 #undef NEW
00013
00017 #define NEW(type, num) calloc(num, sizeof(type));
00018
00019 #undef REALLOC
00020
00025 #define REALLOC(dat, type, num) \
00026 { \
00027 if (dat) \
00028 { \
00029 dat = realloc(dat, sizeof(type) * num); \
00030 } \
00031 }
00032
00033 #undef FREE
00034
00038 #define FREE(dat) \
00039 { \
00040 free(dat); dat = NULL; \
00041 }
00042
00043
00044 #undef IF_FREE
00045
00049 #define IF_FREE(dat) \
00050 { \
00051 if (dat) FREE(dat); \
00052 }
00053
00054 #undef IF_FREE_LIST
00055
00059 #define IF_FREE_LIST(list) \
00060 { \
00061 if (list) { \
00062 ecore_list_destroy(list); \
00063 list = NULL; \
00064 } \
00065 }
00066
00067 #undef IF_FREE_HASH
00068
00072 #define IF_FREE_HASH(hash) \
00073 { \
00074 if (hash) { \
00075 ecore_hash_destroy(hash); \
00076 hash = NULL; \
00077 } \
00078 }
00079
00080 #undef IF_RELEASE
00081
00085 #define IF_RELEASE(item) \
00086 { \
00087 if (item) { \
00088 ecore_string_release(item); \
00089 item = NULL; \
00090 } \
00091 }
00092
00093 #undef ZERO
00094
00099 #define ZERO(ptr, type, num) ptr = memset(ptr, 0, sizeof(type) * (num))
00100
00101 #ifndef MIN
00102
00106 #define MIN(x, y) (((x) > (y)) ? (y) : (x))
00107 #endif
00108
00109 #ifndef MAX
00110
00114 #define MAX(x, y) (((x) > (y)) ? (x) : (y))
00115 #endif
00116
00121 #endif
00122