C
cijo
Hi,
My program has a pointer to a structure declared locally inside a
function to which memory is allocated using malloc and reallocated
later using realloc, and when I try to free the memory at the end of
the function, the program breaks down. While debugging, I find that the
address to which the pointer is pointing is changed during one of the
realloc calls. But as per the documentation on realloc, the change of
address is perfectly normal. Some of my colleagues say the failure in
'free'ing the memory is due to some bug in 'realloc'. I find it hard to
believe though. Is it dependent on the compiler (the IDE is MS Visual
Studion .NET 2003) or could there be something wrong with my code?
My program has a pointer to a structure declared locally inside a
function to which memory is allocated using malloc and reallocated
later using realloc, and when I try to free the memory at the end of
the function, the program breaks down. While debugging, I find that the
address to which the pointer is pointing is changed during one of the
realloc calls. But as per the documentation on realloc, the change of
address is perfectly normal. Some of my colleagues say the failure in
'free'ing the memory is due to some bug in 'realloc'. I find it hard to
believe though. Is it dependent on the compiler (the IDE is MS Visual
Studion .NET 2003) or could there be something wrong with my code?