Thus there is no obvious way for isptr to determine

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: d */ #define PACK(size, alloc) ((size) | (alloc)) /* Read and write a word at address p */ #define GET(p) (*(size_t *)(p)) #define PUT(p, val) (*(size_t *)(p) = (val)) /* Read the size and allocated fields from address p */ #define GET_SIZE(p) (GET(p) & ˜0x7) #define GET_ALLOC(p) (GET(p) & 0x1) /* Given block ptr bp, compute address of its header and footer */ #define HDRP(bp) ((void *)(bp) - WSIZE) #define FTRP(bp) ((void *)(bp) + GET_SIZE(HDRP(bp)) - DSIZE) /* Given block ptr bp, compute address of next and previous blocks */ #define NEXT_BLKP(bp) ((void *)(bp) + GET_SIZE(((void *)(bp) - WSIZE))) #define PREV_BLKP(bp) ((void *)(bp) - GET_SIZE(((void *)(bp) - DSIZE))) code/vm/malloc.c Figure 10.45: Basic constants and macros for manipulating the free list. 10.9. DYNAMIC MEMORY ALLOCATION size t size = GET SIZE(HDRP(NEXT BLKP(bp))); 539 Creating the Initial Free List Before calling mm malloc or mm free, the application must initialize the heap by calling the mm init function (Figure 10.46). The mm init function gets four words from the memory sy...
View Full Document

Ask a homework question - tutors are online