previous | start | next

Implicit Lists

heap_listp
(points here)
hd ft hd free ft hd alloc ft hd alloc ft hd free ft

The first block is pointed to by a global pointer variable, heap_listp.

        static char *heap_listp;
     

Each block has a header and footer. Each one is 4 bytes:

   31 30 29       5  4  3  2  1   0
  -----------------------------------
  | s  s  s  ...  s  s  s  0  0  a/f|
  -----------------------------------

     

where the bits marked s are meaningful and give the size of the block.

Bits 2 and 1 are unused.

Bit 0 is 1 if the block is allocated and 0 if it is free.

The size of the block is assumed to be a multiple of 8.

So in binary the size would have the low order 3 bits equal to 0.

Bits 31 - 3 plus three more 0's are give the size of the block.

The size includes the header and the footer.



previous | start | next