37 releases
Uses old Rust 2015
0.8.11 | Jan 2, 2021 |
---|---|
0.8.10 | Dec 28, 2020 |
0.8.6 | Sep 24, 2020 |
0.8.4 | May 3, 2020 |
0.1.2 | Mar 5, 2016 |
#8 in Memory management
7,462 downloads per month
Used in 13 crates
(8 directly)
35KB
627 lines
linked-list-allocator
Usage
Create a static allocator in your root module:
use linked_list_allocator::LockedHeap;
#[global_allocator]
static ALLOCATOR: LockedHeap = LockedHeap::empty();
Before using this allocator, you need to init it:
pub fn init_heap() {
let heap_start = …;
let heap_end = …;
let heap_size = heap_end - heap_start;
unsafe {
ALLOCATOR.lock().init(heap_start, heap_size);
}
}
Features
use_spin
(default): Provide aLockedHeap
type that implements theGlobalAlloc
trait by using a spinlock.const_mut_refs
(default): Makes theHeap::empty
functionconst
; requires nightly Rust.use_spin_nightly
(default): Makes theLockedHeap::empty
functionconst
, automatically enablesuse_spin
andconst_mut_refs
; requires nightly Rust.alloc_ref
: Provide an implementation of the unstableAllocRef
trait; requires nightly Rust.- Warning: The
AllocRef
trait is still regularly changed on the Rust side, so expect some regular breakage when using this feature.
- Warning: The
License
This crate is dual-licensed under MIT or the Apache License (Version 2.0). See LICENSE-APACHE and LICENSE-MIT for details.
Dependencies
~32KB