I came across this small piece of code in this question and wanted to know
Can the realloc() function move a block of memory to another location when the specified memory space is reduced?
int * a = malloc( 10*sizeof(int) ); int * b = realloc( a, 5*sizeof(int) );
If possible, under what conditions can I expect b have an address different from the address in a ?
c realloc dynamic-memory-allocation
user191776
source share