Skip to content
Snippets Groups Projects
Commit 4f64563d authored by rswindell's avatar rswindell
Browse files

Created handy generic pointer-freeing macros in gen_defs.h:

FREE_AND_NULL, FREE_LIST, and FREE_LIST_ITEMS.
parent 67e7b4e5
Branches
Tags
No related merge requests found
......@@ -249,5 +249,11 @@ typedef struct {
#define FREE free
#endif
/********************************/
/* 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)
#endif /* Don't add anything after this #endif statement */
......@@ -344,11 +344,7 @@ void strListFreeStrings(str_list_t list)
{
size_t i;
if(list!=NULL) {
for(i=0; list[i]!=NULL; i++)
free(list[i]);
list[0]=NULL; /* terminate */
}
FREE_LIST_ITEMS(list,i);
}
void strListFree(str_list_t* list)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment