Why realloc() has problems, revisited
This tip has many graphics. It may load slowly.
A tip-of-the-week reader asked for clarification on the reallocation information presented in a previous tip. That tip talked about manipulating pointers that point into a memory block that will be reallocated.
Here is a snapshot of a small program that allocates some memory, sets a couple of values within the memory, and then reallocates the region:

In the following table, the column on the left contains an Expression List Window that shows the value of the p and q pointers as the program executes. (The program was compiled using gcc on a computer running the Red Hat Linux operating system.) The column on the right describes what you are seeing. The line numbers in this column are those shown in the program snapshot.
You can find tips that we've already sent out in our Tip Archive
Help us improve these tips!