This preview shows page 1. Sign up to view the full content.
Unformatted text preview: zes of words (WSIZE) and double-words (DSIZE), the size of the initial free block and the default size for expanding the heap (CHUNKSIZE), and the number of overhead bytes consumed by the header and footer (OVERHEAD). Manipulating the headers and footers in the free list can be troublesome because it demands extensive use of casting and pointer arithmetic. Thus, we ﬁnd it helpful to deﬁne a small set of macros for accessing and traversing the free list (lines 10–26). The PACK macro (line 10) combines a size and an allocate bit and returns a value that can be stored in a header or footer. The GET macro (line 13) reads and returns the word referenced by argument p. The casting here is crucial. The argument p is typically a (void *) pointer, which cannot be dereferenced directly. Similarly, the PUT macro (line 14) stores val in the word pointed at by argument p. The GET SIZE and GET ALLOC macros (lines 17–18) return the size and allocated bit, respectively, from a header or footer at add...
View Full Document
- Spring '10
- The American