...
The realloc()
function changes the size of a dynamically allocated memory object. The initial size
bytes of the returned memory object are unchanged, but any newly added space is uninitialized, and its value is indeterminate. As in the case of malloc()
, accessing memory beyond the size of the original object is undefined behavior 181186.
It is the programmer's responsibility to ensure that any memory allocated with malloc()
and realloc()
is properly initialized before it is used.
...