previousupnext

3.2.3 Block Append

Block-append happens when an allocator can find no free block suitable to fit or split before reaching the end of the list. The thread carves a new block out of fresh memory past the end of all existing blocks. It sets up a corresponding descriptor and appends that to the list.


The thread sets addr of the new descriptor according to the size of allocation it is required to provide. To reinforce the penult field of the penultimate descriptor, it increments it (CMPXCHG) raising it from one to two. It then overwrites (CMPXCHG) the penult and nxt fields of the end-marker simultaneously, so chaining on the new end-marker. Next it subtracts two (SUB) from the penult field of the descriptor that was formerly penultimate in order to zero it. Finally it returns the addr field of the former end-marker to the calling program.