5 releases
Uses new Rust 2021
new 0.2.1 | Jan 24, 2023 |
---|---|
0.2.0 | Jan 24, 2023 |
0.1.2 | Jan 19, 2022 |
0.1.1 | Jan 19, 2022 |
0.1.0 | Aug 21, 2020 |
#133 in Memory management
74 downloads per month
8KB
97 lines
kernel-alloc-rs
Why?
Rust has many useful abstractions and utils that require heap allocations. String
, Vec
and Box
are some of them. To be able to use them, we need to allocate memory at runtime, which requires a custom allocator.
If you want to find out more about it, please refer to the alloc::GlobalAllocator or alloc::Allocator and the Rust book for global_allocator or allocator_api.
Example
Add the following to your code to define new global allocator:
use kernel_alloc::KernelAlloc;
#[global_allocator]
static GLOBAL: KernelAlloc = KernelAlloc;
Add the following to your code to define new physical allocator:
use kernel_alloc::PhysicalAllocator;
#[global_allocator]
static GLOBAL: PhysicalAllocator = PhysicalAllocator;
Dependencies
~27KB