| Name | Date | Size | #Lines | LOC | ||
|---|---|---|---|---|---|---|
| .. | - | - | ||||
| .github/workflows/ | 03-May-2024 | - | 27 | 22 | ||
| benches/ | 03-May-2024 | - | 193 | 121 | ||
| patches/ | 03-May-2024 | - | 14 | 13 | ||
| src/ | 03-May-2024 | - | 885 | 615 | ||
| .cargo_vcs_info.json | D | 03-May-2024 | 94 | 6 | 6 | |
| .gitignore | D | 03-May-2024 | 29 | 3 | 3 | |
| Android.bp | D | 03-May-2024 | 1 KiB | 44 | 40 | |
| Cargo.toml | D | 03-May-2024 | 1.4 KiB | 57 | 48 | |
| Cargo.toml.orig | D | 03-May-2024 | 783 | 31 | 26 | |
| LICENSE | D | 03-May-2024 | 1 KiB | 8 | 4 | |
| METADATA | D | 03-May-2024 | 696 | 24 | 22 | |
| MODULE_LICENSE_MIT | D | 03-May-2024 | 0 | |||
| OWNERS | D | 03-May-2024 | 47 | 2 | 1 | |
| README.md | D | 03-May-2024 | 1.4 KiB | 48 | 31 | |
| cargo2android.json | D | 03-May-2024 | 121 | 8 | 7 |
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- **`use_spin`** (default): Provide a `LockedHeap` type that implements the [`GlobalAlloc`] trait by using a spinlock. 34- **`const_fn`** (nightly only): Provide const fn version of `LockedHeapWithRescue::new`. 35 36[`GlobalAlloc`]: https://doc.rust-lang.org/nightly/core/alloc/trait.GlobalAlloc.html 37 38## License 39 40Some code comes from phil-opp's linked-list-allocator. 41 42Licensed under MIT License. Thanks phill-opp's linked-list-allocator for inspirations and interface. 43 44[crate-img]: https://img.shields.io/crates/v/buddy_system_allocator.svg 45[crate]: https://crates.io/crates/buddy_system_allocator 46[docs-img]: https://docs.rs/buddy_system_allocator/badge.svg 47[docs]: https://docs.rs/buddy_system_allocator 48