The application calls malloc in the usual manner

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: k function. Extends the heap * by incr bytes and returns the start address of the new area. In * this model, the heap cannot be shrunk. */ void *mem_sbrk(int incr) { void *old_brk = mem_brk; if ( (incr < 0) || ((mem_brk + incr) > mem_max_addr)) { errno = ENOMEM; return (void *)-1; } mem_brk += incr; return old_brk; } code/vm/memlib.c Figure 10.43: memlib.c: Memory system model. 10.9. DYNAMIC MEMORY ALLOCATION 537 The mm init function initializes the allocator, returning 0 if successful and -1 otherwise. The mm malloc and mm free functions have the same interfaces and semantics as their system counterparts. The allocator uses the block format shown in Figure 10.41. The minimum block size is 16 bytes. The free list is organized as an implicit free list, with the invariant form shown in Figure 10.44. prologue block start of heap regular block 1 regular block 2 regular block n epilogue block hdr doubleword aligned 8/1 8/1 hdr ftr hdr ftr ... hdr ftr 0/1 static void *heap_listp Figure 10.44: Invariant form...
View Full Document

This note was uploaded on 09/02/2010 for the course ELECTRICAL 360 taught by Professor Schultz during the Spring '10 term at BYU.

Ask a homework question - tutors are online