Replies: 1 comment 1 reply
-
This is very much doable. Here's how :) The allocator has a component structure - there is the underlying allocator tree, which is sizeless and works in arbitrary units where the smallest arbitrary unit is tracked by a leaf of the tree. The tree is used by the allocator and the allocator converts these arbitrary units to memory sizes and memory locations. The tree maps to a contiguous, power-of-two virtual arena. The allocator supports non-power-of-two sized arenas by masking out the up-to-power-of-two complement in the tree as already allocated. This is currently done by the buddy_toggle_virtual_slots function. If you need to mask out other holes you can make the internal functions non-static and use them in the same way. As long as your program doesn't do a free() to these they will remain masked. |
Beta Was this translation helpful? Give feedback.
-
would it be possible to repurpose this allocator for non contiguous memory? ie. physical memory which has holes and reserved/unusable regions in between usable memory.
Beta Was this translation helpful? Give feedback.
All reactions