I just saw this code:
artist = (char *) malloc(0);
...and I was wondering why would one do this?
Admittedly, I have never seen this before, this is the first time I've seen this syntax, one could say, a classic case of function overkill. In conjunction to Reed's answer, I would like to point out that there is a similar thing, that appears like an overloaded function realloc
:
realloc(foo, size);
. When you pass in a non-NULL pointer and size of zero to realloc, realloc behaves as if you’ve called free(…)realloc(foo, size);
. When you pass in a NULL pointer and size is non-zero, realloc behaves as if you’ve called malloc(…)Hope this helps, Best regards, Tom.