reallocptr 0 is not equivalent to freeptr

suggest change

realloc is conceptually equivalent to malloc + memcpy + free on the other pointer.

If the size of the space requested is zero, the behavior of realloc is implementation-defined. This is similar for all memory allocation functions that receive a size parameter of value 0. Such functions may in fact return a non-null pointer, but that must never be dereferenced.

Thus, realloc(ptr,0) is not equivalent to free(ptr). It may

So in particular the latter two cases are indistinguishable by application code.

This means realloc(ptr,0) may not really free/deallocate the memory, and thus it should never be used as a replacement for free.

Feedback about page:

Optional: your email if you want me to get back to you:

Table Of Contents