It'll only evaluate the pointer once. It's possible to make this a function though, that might be preferable
int* p = malloc(sizeof(int));
FREE(&p);
What if we instead define the macro like this: #define FREE(ptr) do { \
__typeof__(ptr)* const __x = &(ptr); \
free(*__x); *__x = NULL; \
} while(0)
Then make usage slightly shorter, as well as more similar to free(): int* p = malloc(sizeof(int));
FREE(p);Maybe someone else could figure out how to do it properly, since I'd definitely prefer a function.