![]() |
![]() |
![]() |
![]() |
![]() |
|
Now, as soon as analyze_trades works on the test.data file a
second time, it allocates memory for three new trade objects in
addition to the memory previously allocated for three other trade
objects:
0 1 2 <-- Trades
| | | array
v v v index
------------------- ------------------- -----------------
----*-------------------*-------------------*-------------------*---
| First pointer | Second pointer | Third pointer |
---*---------*---------*---------*---------*---------*---------*----
| | |
v v v
*-----------------* *-----------------* *-----------------*
| Fourth allocated| | Fifth allocated | | Sixth allocated |
| chunk of memory | | chunk of memory | | chunk of memory |
*-----------------* *-----------------* *-----------------*
*-----------------* *-----------------* *-----------------*
| First allocated | | Second allocated| | Third allocated |
| chunk of memory | | chunk of memory | | chunk of memory |
*-----------------* *-----------------* *-----------------*
Now, however, there are no pointers to the first three of the memory chunks
allocated at run time for trade objects. Accordingly, they are
completely inaccessible.