| Crates.io | index_alloc |
| lib.rs | index_alloc |
| version | 0.1.1 |
| created_at | 2024-05-04 16:29:13.747138+00 |
| updated_at | 2024-05-16 17:32:01.407261+00 |
| description | A toy static allocator wich can serve as a global_allocator. |
| homepage | |
| repository | https://github.com/Adi-df/index_alloc/ |
| max_upload_size | |
| id | 1229696 |
| size | 47,150 |
A simple, toy static Allocator which use a fixed length array to store allocated data.
This crate expose a struct [IndexAllocator] which implement [GlobalAlloc] so it can be uses as the global allocator in no_std environment.
Disadvantages :
Even though it seems unusable, it has plenty of advantages :
To store allocated memory, [IndexAllocator] uses a MemoryIndex which stores a list of regions containing the state of the region (size, from which address, used status). For instance :
use index_alloc::IndexAllocator;
#[global_allocator]
static ALLOCATOR: IndexAllocator<2048, 16> = IndexAllocator::empty();
fn main() {
let test_str = String::from("Hello World");
println!("{test_str}");
}
See more example in the Repository's Examples.