You can be safely 100% sure of that. Under both C standards.
The memory location will only change if at the current position there is no
room for a continous block with the requested size.
1. This statement is false. realloc() is free to change the block's
address even if the old size is equal to the new size. Under NO
circumstance is realloc() constrained to return the old address.
2. This has absolutely NOTHING to do with the OP's question! He was
talking about the *contents* of the reallocated memory block, not
about the circumstances when the memory block will have its address
changed.
So, could you, please, stop posting bullshit to this newsgroup?
The actual C89 specification is:
4.10.3.4 The realloc function
Synopsis
#include <stdlib.h>
void *realloc(void *ptr, size_t size);
Description
The realloc function changes the size of the object pointed to by
ptr to the size specified by size . The contents of the object shall
be unchanged up to the lesser of the new and old sizes. If the new
size is larger, the value of the newly allocated portion of the object
is indeterminate. If ptr is a null pointer, the realloc function
behaves like the malloc function for the specified size. Otherwise,
if ptr does not match a pointer earlier returned by the calloc ,
malloc , or realloc function, or if the space has been deallocated by
a call to the free or realloc function, the behavior is undefined. If
the space cannot be allocated, the object pointed to by ptr is
unchanged. If size is zero and ptr is not a null pointer, the object
it points to is freed.
Returns
The realloc function returns either a null pointer or a pointer to
the possibly moved allocated space.
Dan