The standard specifies that the contents of reallocated space is undefined if the new size if larger.
If preserving the contents of the previously-allocated space is important, is the best way to reallocate data as follows: copying it to the stack, freeing it from the heap, allocating on the heap with more space, and copying back to the heap? Is there another safe way to do this?
Would the best way to implement a data structure like a dynamically growing array that only grows be in the form a linked list?