Home Segments Index Top Previous Next

575: Mainline

Although the revised analyze_trades function uses the free function to reclaim the memory consumed by obsolete and inaccessible structure objects, those objects themselves may contain pointers to character arrays created at run time. In an earlier version of analyze_trades, shown in Segment 514, you saw, for example, that it is possible to insert a pointer to a trade-describing string that occupies space allocated at run time.

To reclaim such memory, you need to place another call to free just before the structure-object-reclaiming free.

... 
free (trade_pointers[limit] -> description); 
free (trade_pointers[limit]); 
...