The only thing is worth substituting is free(), the C standard doesn't say that after freeing the memory the pointer has to be NULLed;
#define SAFE_FREE(m) \
{ \
if(m) \
{ \
free(m); \
m = NULL; \
} \
}
A good practice is to NULL the freed pointer, that will help to catch potential problems earlier aspesially if you have a habit to use assert for every internal functions, like this:
void foo_internal(void* p)
{
assert(p != NULL);
// ...
}
If you do not NULL the pointer after freeing it and call the func the assert will never be triggered on the most compilers and platforms (memory allocation are platform specific).
That might seem not a big deal if you have IDE debugger and can step through the code but in some cases, like UEFI, embedded, etc. where you don't have a debugger that simple practice would save a lot of headache!