~ren/polymorph-allocator

a simple Rust memory allocator
f0b7562f — Lauren Jenkinson 8 months ago
release: v1.2.0
04961a30 — Lauren Jenkinson 8 months ago
lib: Change AllocErr to AllocError
29cfc5db — Lauren Jenkinson 1 year, 2 months ago
release: v1.1.0

refs

main
browse  log 

clone

read-only
https://git.sr.ht/~ren/polymorph-allocator
read/write
git@git.sr.ht:~ren/polymorph-allocator

You can also use your local clone with git send-email.

#polymorph-allocator

A simple Rust memory allocator, designed for polymorphOS.

This crate takes heavy inspiration from awooOS/dmm, a simple C memory allocator for bare-metal uses.

In it's current state, polymorph-allocator is usable, however it is likely to be slow for lots of small allocations. This is an artifact of it's design - every allocation requires iterating through the entire list of allocated chunks until a free chunk is found.

The next major release of polymorph-allocator is planned to completely change how the allocation works, which will improve it's speed, but also it's complexity. The current version of polymorph-allocator is rather simple to understand, and so it could be good as a learning tool. Who knows.

#Usage

use polymorph_allocator::LockedAllocator;

#[global_allocator]
pub static ALLOCATOR: LockedAllocator = LockedAllocator::empty();

fn main() {
    // For a 32MB heap starting at 1MB in RAM:
    ALLOCATOR.lock().add_region(0x100000, 0x2000000);
}

#License

polymorph-allocator is licensed under the MIT License, the same license as the rest of polymorphOS.

You can find this license in the LICENSE file in the top level of this repository.