[Oberon] PO2013 - Show Heap Blocks

Paul Reed paulreed at paddedcell.com
Tue Jun 23 10:46:36 CEST 2020


Hi Tomas,

> Trying to read heap allocation code...
> list3 points to the last free 32-block, it is a chain of 32-blocks
> going back to HeapOrg(60000H)

Each free list is a chain of blocks that is terminated with a next 
pointer of NIL (ie a singly-linked list).

(The block at Kernel.heapOrg [80000H in the published system] may be 
allocated, not free, so that's not what terminates the list.)


> I do not see yet, which part of the code terminates the list with 0,
> where, when?

In Kernel.Init, the lists are each initialised to NIL.

Each free block which is added to the list is added at the front (head) 
of the list, and its next pointer points to the rest of the list (which 
may be NIL).

It is possible to add items onto a singly-linked list at the other end 
(tail), if you keep a note of the tail, but if the order doesn't matter, 
it's not necessary.

HTH
Paul


More information about the Oberon mailing list