linked-list-allocator icon indicating copy to clipboard operation
linked-list-allocator copied to clipboard

Implementation of a segmented heap

Open pantsman0 opened this issue 4 months ago • 0 comments

This widens the implementation of the Heap struct into a SegmentedHeap, allowing multiple regions to be used for heap allocation. There is not, however, any fitting strategy - all allocations using allocate_first_fit will always use the first memory region, unless it fails. Allocations will cascade down the array of hole lists, failing to allocate when all regions fail to allocate.

This also makes the assumption that memory regions are non-overlapping, so construction from a list of pointer+sizes is unsafe and that invariant is left to the consumer to enforce.

WIP as this does not extend the testing or fuzzing to the wider implementation, but should theoretically be fine as the changes do not actually change any of the allocation login in hole.rs.

There is another change in there to make HoleList::allocate_first_fit return an Option type, which was done to make a functional pattern work in SegmentedHeap::allocate_first_fit (i.e. using Iterator::filter_map) but this can be reverted if we don't want that change mixed in with the other changes.

pantsman0 avatar Oct 21 '24 03:10 pantsman0