24 releases

0.11.0 Sep 21, 2024
0.10.0 Jul 1, 2024
0.9.1 Jan 27, 2024
0.9.0 Dec 14, 2022
0.1.2 Mar 18, 2019

#94 in Embedded development

Download history 3262/week @ 2024-12-22 1719/week @ 2024-12-29 2086/week @ 2025-01-05 3729/week @ 2025-01-12 4092/week @ 2025-01-19 2360/week @ 2025-01-26 3679/week @ 2025-02-02 3749/week @ 2025-02-09 4341/week @ 2025-02-16 4147/week @ 2025-02-23 4917/week @ 2025-03-02 5298/week @ 2025-03-09 7737/week @ 2025-03-16 6690/week @ 2025-03-23 4758/week @ 2025-03-30 5887/week @ 2025-04-06

25,693 downloads per month
Used in 14 crates (7 directly)

MIT license

32KB
642 lines

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

  • alloc (default): Provide FrameAllocator and LockedFrameAllocator, which depend on a global allocator.
  • use_spin (default): Provide a LockedHeap type that implements the GlobalAlloc trait by using a spinlock.

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.

Dependencies

~39KB