This preview shows page 1. Sign up to view the full content.
Unformatted text preview: ear in the total number of heap blocks, the implicit free list is not appropriate for a general-purpose allocator (although it might be ﬁne for a special-purpose allocator where the number of heap blocks is known beforehand to be small). A better approach is to organize the free blocks into some form of explicit data structure. Since by deﬁnition the body of a free block is not needed by the program, the pointers that implement the data structure can be stored within the bodies of the free blocks. For example, the heap can be organized as a doubly-linked free list by including a pred (predecessor) and succ (successor) pointer in each free block, as shown in Figure 10.50. Using a doubly-linked list instead of an implicit free list reduces the ﬁrst ﬁt allocation time from linear in the total number of blocks to linear in the number of free blocks. However, the time to free a block can be either linear or constant, depending on the policy we choose for ordering the blocks in the free list. One approach is to maintain the list in last-in ﬁrst-out (LIFO) order by inserting newly freed blocks at the beginning of the list. With a LIFO ordering and a...
View Full Document
- Spring '10
- The American