• Home
Name Date Size #Lines LOC

..--

.github/workflows/03-May-2024-2722

benches/03-May-2024-193121

patches/03-May-2024-1413

src/03-May-2024-885615

.cargo_vcs_info.jsonD03-May-202494 66

.gitignoreD03-May-202429 33

Android.bpD03-May-20241 KiB4440

Cargo.tomlD03-May-20241.4 KiB5748

Cargo.toml.origD03-May-2024783 3126

LICENSED03-May-20241 KiB84

METADATAD03-May-2024696 2422

MODULE_LICENSE_MITD03-May-20240

OWNERSD03-May-202447 21

README.mdD03-May-20241.4 KiB4831

cargo2android.jsonD03-May-2024121 87

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- **`use_spin`** (default): Provide a `LockedHeap` type that implements the [`GlobalAlloc`] trait by using a spinlock.
34- **`const_fn`** (nightly only): Provide const fn version of `LockedHeapWithRescue::new`.
35
36[`GlobalAlloc`]: https://doc.rust-lang.org/nightly/core/alloc/trait.GlobalAlloc.html
37
38## License
39
40Some code comes from phil-opp's linked-list-allocator.
41
42Licensed under MIT License. Thanks phill-opp's linked-list-allocator for inspirations and interface.
43
44[crate-img]:     https://img.shields.io/crates/v/buddy_system_allocator.svg
45[crate]:         https://crates.io/crates/buddy_system_allocator
46[docs-img]:      https://docs.rs/buddy_system_allocator/badge.svg
47[docs]:          https://docs.rs/buddy_system_allocator
48