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: 10.9. DYNAMIC MEMORY ALLOCATION 543 If there is a fit, 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 find a fit, 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 first-fit 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

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