Name | Date | Size | #Lines | LOC | ||
---|---|---|---|---|---|---|
.. | - | - | ||||
benches/ | 25-Apr-2025 | - | 190 | 119 | ||
src/ | 25-Apr-2025 | - | 935 | 642 | ||
.cargo-checksum.json | D | 25-Apr-2025 | 762 | 1 | 1 | |
Android.bp | D | 25-Apr-2025 | 1.3 KiB | 50 | 45 | |
Cargo.toml | D | 25-Apr-2025 | 1.4 KiB | 60 | 51 | |
LICENSE | D | 25-Apr-2025 | 1 KiB | 8 | 4 | |
METADATA | D | 25-Apr-2025 | 445 | 18 | 17 | |
MODULE_LICENSE_MIT | D | 25-Apr-2025 | 0 | |||
README.md | D | 25-Apr-2025 | 1.4 KiB | 50 | 33 | |
cargo_embargo.json | D | 25-Apr-2025 | 431 | 24 | 23 | |
rules.mk | D | 25-Apr-2025 | 781 | 26 | 18 |
README.md
1# buddy_system_allocator 2 3[![Crates.io version][crate-img]][crate] 4[![docs.rs][docs-img]][docs] 5 6An (almost) drop-in replacement for [phil-opp/linked-list-allocator](https://github.com/phil-opp/linked-list-allocator). But it uses buddy system instead. 7 8## Usage 9 10To use buddy_system_allocator for global allocator: 11 12```rust 13use buddy_system_allocator::LockedHeap; 14 15#[global_allocator] 16static HEAP_ALLOCATOR: LockedHeap = LockedHeap::<32>::empty(); 17``` 18 19To init the allocator: 20 21```rust 22unsafe { 23 HEAP_ALLOCATOR.lock().init(heap_start, heap_size); 24 // or 25 HEAP_ALLOCATOR.lock().add_to_heap(heap_start, heap_end); 26} 27``` 28 29You can also use `FrameAllocator` and `LockedHeapWithRescue`, see their documentation for usage. 30 31## Features 32 33- **`alloc`** (default): Provide `FrameAllocator` and `LockedFrameAllocator`, which depend on a 34 global allocator. 35- **`use_spin`** (default): Provide a `LockedHeap` type that implements the [`GlobalAlloc`] trait by 36 using a spinlock. 37 38[`GlobalAlloc`]: https://doc.rust-lang.org/nightly/core/alloc/trait.GlobalAlloc.html 39 40## License 41 42Some code comes from phil-opp's linked-list-allocator. 43 44Licensed under MIT License. Thanks phill-opp's linked-list-allocator for inspirations and interface. 45 46[crate-img]: https://img.shields.io/crates/v/buddy_system_allocator.svg 47[crate]: https://crates.io/crates/buddy_system_allocator 48[docs-img]: https://docs.rs/buddy_system_allocator/badge.svg 49[docs]: https://docs.rs/buddy_system_allocator 50