C: do {...} while(0)?
- by igul222
I'm working on some C code filled with macros like this:
#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
Can anyone explain what this macro does, and why do {} while(0) is needed? Wouldn't that just execute the code once?