3 ms·
How much memory does malloc(0) allocate?
- seppo0010 13y ago> One side thinks that malloc(0) should return a null pointer and be done with it, which sounds like a fine idea until you realize that you can't call free or realloc on the same pointer. Calling free(NULL); does nothing, as expected, and calling realloc(NULL, size_t) is the same as calling malloc(size_t), so it does not have that as a bad side effects.