The balanced tree approach is correct in the sense

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: stem and initializes code/vm/malloc.c 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 int mm_init(void) { /* create the initial empty heap */ if ((heap_listp = mem_sbrk(4*WSIZE)) == NULL) return -1; PUT(heap_listp, 0); /* PUT(heap_listp+WSIZE, PACK(OVERHEAD, 1)); /* PUT(heap_listp+DSIZE, PACK(OVERHEAD, 1)); /* PUT(heap_listp+WSIZE+DSIZE, PACK(0, 1)); /* heap_listp += DSIZE; alignment padding */ prologue header */ prologue footer */ epilogue header */ /* Extend the empty heap with a free block of CHUNKSIZE bytes */ if (extend_heap(CHUNKSIZE/WSIZE) == NULL) return -1; return 0; } code/vm/malloc.c Figure 10.46: mm init: Creates a heap with an initial free block. them to create the empty free list (lines 4–10). It then calls the extend heap function (Figure 10.47), which extends the heap by CHUNKSIZE bytes and creates the initial free block. At this point, the allocator is initialized and ready to accept allocate and free requests from the application. The extend heap function is invoked in two different circumstan...
View Full Document

Ask a homework question - tutors are online