So if you do:
void *ptr = NULL;
What is the best way to check if that void pointer is NULL?
My workaround for now is this:
if (*(void**)ptr == NULL) ...
But this doesn't seem like the best way, as I'm implicitly assuming ptr is of type void** (which it isn't).
I'd simply write if (!ptr)
.
NULL
is basically just 0
and !0
is true.