commit | 1ffd4ebeeba2cbcb1d1cd41ffbbd9aa0f55f73a7 | [log] [tgz] |
---|---|---|
author | Andrew Walbran <qwandor@google.com> | Wed Apr 27 20:09:29 2022 +0000 |
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | Wed Apr 27 20:09:29 2022 +0000 |
tree | 3851369b22a286c1e678bc66fb996d2ffbcd9fbc | |
parent | 105511c7f26d817bce5e9dadce7b4624a93955a1 [diff] | |
parent | 7715deb348c705405891f86f876ce36677cdf268 [diff] |
Initial import of buddy_system_allocator crate. am: 05bbb90269 am: 1509275376 am: 377395a661 am: 7715deb348 Original change: https://android-review.googlesource.com/c/platform/external/rust/crates/buddy_system_allocator/+/2076461 Change-Id: Ief67deb82a97e1d71052d14197891bc6bb857b0a Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
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::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.