As noted in the comments, case 3 in the question (without memory) is erroneous; realloc() will return NULL if there is no memory available [question is now fixed].
Steve McConnell in "Code Complete" indicates that if you store the return value from realloc() in a single copy of the original pointer, when realloc() fails, you simply skipped memory. I.e:
void *ptr = malloc(1024); ... if ((ptr = realloc(ptr, 2048)) == 0) { }
Different realloc () implementations will behave differently. The only thing that can be assumed is that the data will always be moved - you will always receive a new address when the memory is reloaded.
As someone else remarked, if this bothers you, maybe it's time to look at your algorithms.
Jonathan leffler
source share