Bug: 230395700

Clone this repo:
  1. d4c4cf4 Migrate 25 crates to monorepo am: fc60ad5bc7 by James Farrell · 5 months ago main master
  2. fc60ad5 Migrate 25 crates to monorepo by James Farrell · 5 months ago main-16k
  3. 0f039f8 Update Android.bp by running cargo_embargo am: d216d37747 by James Farrell · 6 months ago
  4. d216d37 Update Android.bp by running cargo_embargo by James Farrell · 6 months ago
  5. 1070c66 Update Android.bp by running cargo_embargo am: 49ddfcbe66 am: 1fc45034ca by James Farrell · 8 months ago android15-tests-dev aml_ads_350923060 aml_art_350913340 aml_art_351011240 aml_art_351011340 aml_art_351110180 aml_cbr_350910020 aml_cbr_351011020 aml_doc_350915120 aml_doc_351012120 aml_ext_350912020 aml_hef_350921160 aml_hef_351016140 aml_med_350914000 aml_med_351010060 aml_net_350911020 aml_net_351010000 aml_net_351010020 aml_odp_350923040 aml_per_350910080 aml_per_351014000 aml_res_351011000 aml_rkp_350910000 aml_rkp_351011000 aml_sdk_350910000 aml_sta_350911020 aml_swc_350914020 aml_swc_350914040 aml_swc_350914060 aml_swc_351010060 aml_tet_350911120 aml_tet_351010220 aml_uwb_350911040 aml_uwb_351011040

buddy_system_allocator

Crates.io version docs.rs

An (almost) drop-in replacement for phil-opp/linked-list-allocator. But it uses buddy system instead.

Usage

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.

Features

  • 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.

License

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.