Skip to content
Snippets Groups Projects
Commit 7d3a046d authored by rswindell's avatar rswindell
Browse files

Created convenience macros: INT_TO_BOOL() and COUNT_LIST_ITEMS().

parent d8b90a46
Branches
Tags
No related merge requests found
......@@ -132,6 +132,9 @@ enum {
#define TRUE 1
#define FALSE 0
#endif
#ifndef INT_TO_BOOL
#define INT_TO_BOOL(x) ((x)?TRUE:FALSE)
#endif
#ifndef HANDLE
#define HANDLE void*
#endif
......@@ -252,8 +255,14 @@ typedef struct {
/********************************/
/* Handy Pointer-freeing Macros */
/********************************/
#define FREE_AND_NULL(x) if(x!=NULL) { FREE(x); x=NULL; }
#define FREE_LIST_ITEMS(list,i) for(i=0;list && list[i];i++) { FREE_AND_NULL(list[i]); }
#define FREE_LIST(list,i) FREE_LIST_ITEMS(list,i) FREE_AND_NULL(list)
#define FREE_AND_NULL(x) if(x!=NULL) { FREE(x); x=NULL; }
#define FREE_LIST_ITEMS(list,i) for(i=0;list!=NULL && list[i]!=NULL;i++) \
{ FREE_AND_NULL(list[i]); }
#define FREE_LIST(list,i) FREE_LIST_ITEMS(list,i) FREE_AND_NULL(list)
/********************************/
/* Other Pointer-List Macros */
/********************************/
#define COUNT_LIST_ITEMS(list,i) for(i=0;list!=NULL && list[i]!=NULL;i++);
#endif /* Don't add anything after this #endif statement */
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment