• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..--

benches/25-Apr-2025-190119

src/25-Apr-2025-935642

.cargo-checksum.jsonD25-Apr-2025762 11

Android.bpD25-Apr-20251.3 KiB5045

Cargo.tomlD25-Apr-20251.4 KiB6051

LICENSED25-Apr-20251 KiB84

METADATAD25-Apr-2025445 1817

MODULE_LICENSE_MITD25-Apr-20250

README.mdD25-Apr-20251.4 KiB5033

cargo_embargo.jsonD25-Apr-2025431 2423

rules.mkD25-Apr-2025781 2618

README.md

1# buddy_system_allocator
2
3[![Crates.io version][crate-img]][crate]
4[![docs.rs][docs-img]][docs]
5
6An (almost) drop-in replacement for [phil-opp/linked-list-allocator](https://github.com/phil-opp/linked-list-allocator). But it uses buddy system instead.
7
8## Usage
9
10To use buddy_system_allocator for global allocator:
11
12```rust
13use buddy_system_allocator::LockedHeap;
14
15#[global_allocator]
16static HEAP_ALLOCATOR: LockedHeap = LockedHeap::<32>::empty();
17```
18
19To init the allocator:
20
21```rust
22unsafe {
23    HEAP_ALLOCATOR.lock().init(heap_start, heap_size);
24    // or
25    HEAP_ALLOCATOR.lock().add_to_heap(heap_start, heap_end);
26}
27```
28
29You can also use `FrameAllocator` and `LockedHeapWithRescue`, see their documentation for usage.
30
31## Features
32
33- **`alloc`** (default): Provide `FrameAllocator` and `LockedFrameAllocator`, which depend on a
34  global allocator.
35- **`use_spin`** (default): Provide a `LockedHeap` type that implements the [`GlobalAlloc`] trait by
36  using a spinlock.
37
38[`GlobalAlloc`]: https://doc.rust-lang.org/nightly/core/alloc/trait.GlobalAlloc.html
39
40## License
41
42Some code comes from phil-opp's linked-list-allocator.
43
44Licensed under MIT License. Thanks phill-opp's linked-list-allocator for inspirations and interface.
45
46[crate-img]: https://img.shields.io/crates/v/buddy_system_allocator.svg
47[crate]: https://crates.io/crates/buddy_system_allocator
48[docs-img]: https://docs.rs/buddy_system_allocator/badge.svg
49[docs]: https://docs.rs/buddy_system_allocator
50