commit | 6ee355eb9dd52d35124ebef065d4cd24de8b37dc | [log] [tgz] |
---|---|---|
author | Sam Saccone <[email protected]> | Tue Jul 18 23:44:45 2023 +0000 |
committer | Automerger Merge Worker <[email protected]> | Tue Jul 18 23:44:45 2023 +0000 |
tree | ef63e5c08cc4d140d31894bfcf3863a2a5f03f5d | |
parent | 931f4b023cac999e4ed3ff5c4deb18fa13becdbb [diff] | |
parent | 7ec01dcd0d7154111c3cc68be2b05bff8288ad9f [diff] |
Move OWNER reference master=>main. am: 2d7f60bfe8 am: 5e93f764be am: d8c4433b55 am: 67f4fcb869 am: 7ec01dcd0d Original change: https://android-review.googlesource.com/c/platform/external/rust/crates/buddy_system_allocator/+/2662695 Change-Id: I767e1dae5740d8349cfe97f62476aa9ba1c9e537 Signed-off-by: Automerger Merge Worker <[email protected]>
An (almost) drop-in replacement for phil-opp/linked-list-allocator. But it uses buddy system instead.
To use buddy_system_allocator for global allocator:
use buddy_system_allocator::LockedHeap; #[global_allocator] static HEAP_ALLOCATOR: LockedHeap = LockedHeap::<32>::empty();
To init the allocator:
unsafe { HEAP_ALLOCATOR.lock().init(heap_start, heap_size); // or HEAP_ALLOCATOR.lock().add_to_heap(heap_start, heap_end); }
You can also use FrameAllocator
and LockedHeapWithRescue
, see their documentation for usage.
use_spin
(default): Provide a LockedHeap
type that implements the GlobalAlloc
trait by using a spinlock.const_fn
(nightly only): Provide const fn version of LockedHeapWithRescue::new
.Some code comes from phil-opp's linked-list-allocator.
Licensed under MIT License. Thanks phill-opp's linked-list-allocator for inspirations and interface.