Archived

This topic is now archived and is closed to further replies.

ShmeeBegek

Realloc and data integrity

Recommended Posts

ShmeeBegek    196
I''m wondering whether or not the realloc function maintains the values of data (even in the case that a different pointer is returned than was passed to realloc). I''ve looked in the MSDN documentation on this issue and I have found nothing of pertinence. Thanks, ~SPH

Share this post


Link to post
Share on other sites
SiCrane    11839
The contents of the two blocks will be the same up to the minimum of the new and the old size of the buffer.

Share this post


Link to post
Share on other sites
VolkerG    151
Taken from the MSDN library:

The size argument gives the new size of the block, in bytes. The contents of the block are unchanged up to the shorter of the new and old sizes, although the new block can be in a different location. Because the new block can be in a new memory location, the pointer returned by realloc is not guaranteed to be the pointer passed through the memblock argument.

Share this post


Link to post
Share on other sites