#memory-allocator #heap-memory #bare-metal #allocator #raspberry-pi #ruspiro #heap-allocator

nightly sys no-std ruspiro-allocator

Simple and lightweight heap memory allocator for Raspberry Pi baremetal environments

14 releases

0.5.0 Sep 18, 2020
0.4.6 Jan 2, 2022
0.4.5 Apr 27, 2021
0.4.2 Sep 19, 2020
0.0.2 Jul 30, 2019

#2113 in Embedded development

Download history 123/week @ 2024-07-29 12/week @ 2024-09-23 28/week @ 2024-09-30

94 downloads per month
Used in ruspiro-sdk

MIT/Apache

28KB
312 lines

RusPiRo - Custom Allocator

This crate provides a custom allocator for heap memory. If any baremetal crate uses functions and structures from the alloc crate an allocator need to be provided as well. However, this crate does not export any public API to be used. It only encapsulates the memory allocator that shall be linked into the binary.

CI Latest Version Documentation License

Pre-Requisits

This crate requires to be buil with nightly as it uses the feature alloc_error_handler which is not stable yet. When this crate is used with the Raspberry Pi it also requires the MMU to be configured and enables as it uses atomic operations to provide the lock free memory allocations.

Usage

To use the crate just add the following dependency to your Cargo.toml file:

[dependencies]
ruspiro-allocator = "0.4.6"

Once done the access to the custom allocator is available and will be linked with your project if you add the usage to your crates main rust file:

extern crate ruspiro_allocator;

Wherever you define the usage of the ruspiro-allocator crate the dynamic structures requiring heap memory allocations from the alloc crate could be used like so:

#[macro_use]
extern crate alloc;
use alloc::vec::*;
use alloc::boxed::*;

fn demo() {
    let mut v: Vec<u32> = vec![10, 20];
    let b: Box<u16> = Box::new(10);
    v.push(12);
}

License

Licensed under Apache License, Version 2.0, (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0) or MIT (LICENSE-MIT or http://opensource.org/licenses/MIT)) at your choice.

Dependencies