Bug: 230395700

Clone this repo:
  1. eb81bcb Migrate to cargo_embargo. am: bbe92c08da am: 237e7e9fb0 am: 7e9c710cad by Andrew Walbran · 6 months ago main master
  2. 2936271 Use dep-suffixes rather than dependency-suffix. am: 5fd5854e12 am: 936d96d1b7 am: f746ef37ac by Andrew Walbran · 6 months ago
  3. 43fb475 Migrate to cargo_embargo. am: bbe92c08da am: bb3271f501 am: 6e930c0a72 by Andrew Walbran · 6 months ago
  4. 5757f35 Use dep-suffixes rather than dependency-suffix. am: 5fd5854e12 am: 71cdc5a455 am: 87819b73a1 by Andrew Walbran · 6 months ago
  5. 7e9c710 Migrate to cargo_embargo. am: bbe92c08da am: 237e7e9fb0 by Andrew Walbran · 6 months ago

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.