I want to write macro in c code to freeing many pointers like this :
FREE(ptr1, ptr2, ptr3, ptr4, ptrx);
For me, this is better than
You can pass variable number of arguments in macro. Following code works fine:
#define FREE_ALL(...) \ do { \ int i=0;\ void *pta[] = {__VA_ARGS__}; \ for(i=0; i < sizeof(pta)/sizeof(void*); i++) \ { \ free(pta[i]); \ }\ } while(0)