Debugging Memory Problems with MemoryScape : Chapter 1 Locating Memory Problems : Event and Error Notification : Types of Problems : Tracking realloc() Problems
Tracking realloc() Problems
The following program passes a misaligned address to the realloc() function.
int main (int argc, char *argv[])
{
char *s, *bad_s, *realloc_s;
/* Get some memory */
s = malloc(sizeof(int)*64);
/* Reallocate memory using a misaligned address */
bad_s = s + 8;
realloc_s = realloc(bad_s, sizeof(int)*256));
return 0;
}
In a similar fashion, MemoryScape detects realloc() problems caused by passing addresses to memory sections whose memory your program cannot free. For example, MemoryScape detects problems if you try to do any of the following:
*Reallocate stack memory.
*Reallocate memory in the data section.
*Reallocate memory in the bss section.

Related Topics