o1heap-rs
Rust bindings for o1heap - a constant-time deterministic memory allocator for hard real-time systems.
Features
- Constant-time O(1) allocation and deallocation
- Deterministic behavior suitable for real-time systems
- No-std compatible - designed for embedded systems
- Bounded fragmentation - predictable memory usage
Installation
[]
= "0.0.2"
Usage
As Global Allocator (STM32)
extern crate alloc;
use Vec;
use ;
use addr_of_mut;
use entry;
use O1Heap;
use panic_halt as _;
;
static mut ARENA: Arena = Arena;
static HEAP: O1Heap = empty;
!
Alignment
o1heap guarantees that all allocated memory is aligned to:
- 32-bit systems: 16 bytes
- 64-bit systems: 32 bytes
This alignment is available as o1heap::ALIGNMENT.
Diagnostics
let diag = heap.diagnostics;
println!;
println!;
println!;
println!;
assert!;
Thread Safety
o1heap is not thread-safe. If you need to use it from multiple threads or interrupt contexts, you must provide external synchronization (e.g., critical sections, mutexes).
License
MIT license. The underlying o1heap C library is also MIT licensed.