flâneur — a map of the web's best reading

Memory allocator | CS 162 HW 4

cs162.org · 598 words · saved by 1 readers

There are many ways to structure a memory allocator. In this part of the homework, you will be implementing a memory allocator using a linked list of memory blocks, as described in the previous section. In this section, we’ll describe how allocation, deallocation, and reallocation should work in this scheme. To make your implementation succeed, you will need to modify mm_alloc.c. The user will pass in the requested allocation size. Make sure the returned pointer is pointing to the beginning of the allocated space, not your metadata header. One simple algorithm for finding available memory is called first fit. When your memory allocator is called to allocate some memory, it iterates through its blocks until it finds a sufficiently large free block of memory. Here are some implementation details to be aware of. If no sufficiently large free block is found, use sbrk to create more space on the heap. If the first block of memory you find is so large that it can accommodate both the newly a

Explore this link on the map →

saved by