This preview shows page 1. Sign up to view the full content.
Unformatted text preview: 10.9. DYNAMIC MEMORY ALLOCATION 543 If there is a ﬁt, then the allocator places the requested block and optionally splits the excess (line 19), and then returns the address of the newly allocated block (line 20). If the allocator cannot ﬁnd a ﬁt, then it extends the heap with a new free block (lines 24–26), places the requested block in the new free block and optionally splitting the block (line 27), and then return a pointer to the newly allocated block (line 28). Practice Problem 10.8:
Implement a find fit function for the simple allocator described in Section 10.9.12. static void *find_fit(size_t asize) Your solution should perform a ﬁrst-ﬁt search of the implicit free list. Practice Problem 10.9:
Implement a place function for the example allocator. static void place(void *bp, size_t asize) Your solution should place the requested block at the beginning of the free block, splitting only if the size of the remainder would equal or exceed the minimum block size. 10.9.13 Explicit Free Lists
The implicit free list provides us with a simple way to introduce some basic allocator concepts. However, because block allocation is lin...
View Full Document