commit | 432c2fc4a4ff4cab9b068a7f686c2e66a0316a94 | [log] [tgz] |
---|---|---|
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | Wed Jun 07 04:51:06 2023 +0000 |
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | Wed Jun 07 04:51:06 2023 +0000 |
tree | ea70d954d661d2cd8415f32097c5a20398c35d39 | |
parent | d6ad9c68c03dc6198ed0cfb7bcd5acd05ac847fd [diff] | |
parent | 6159b18b27f1172cc8bfe32e20e01ce9050b84a6 [diff] |
Snap for 10273262 from 6159b18b27f1172cc8bfe32e20e01ce9050b84a6 to sdk-release Change-Id: I3a1463149fc85e0892a801cc22296a1e0ceb0ede
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.