commit | aa84e55f51be4284e4f8e16ce915eaa8869b81e9 | [log] [tgz] |
---|---|---|
author | Bob Badour <bbadour@google.com> | Fri Apr 29 19:49:35 2022 +0000 |
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | Fri Apr 29 19:49:35 2022 +0000 |
tree | 6c05c956000c88081267f48e16e8519eeadd3ae1 | |
parent | 1ffd4ebeeba2cbcb1d1cd41ffbbd9aa0f55f73a7 [diff] | |
parent | a29ede09d0c9d8120795fa99adea20f2337e1b86 [diff] |
[LSC] Add LOCAL_LICENSE_KINDS to external/rust/crates/buddy_system_allocator am: 04dc6225eb am: 7158eeee06 am: a6c30bf75e am: a29ede09d0 Original change: https://android-review.googlesource.com/c/platform/external/rust/crates/buddy_system_allocator/+/2080320 Change-Id: I4d8b5f8d939d24619f5f5e80e7b978cdc56ddbc8 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.