Portable linked-list allocator designed for baremetal systems

Overview

Palloc

docs.rs crates.io

Portable linked-list allocator for embedded / baremetal systems.

Using the crate

Include this in the [dependencies] section of Cargo.toml

palloc = "0.1.0"

This crate uses unstable features of Rust, so it requires the nightly update channel. Update the toolchain for your project folder with:

rustup override set nightly

Crate features

  • spin (default): provides a GlobalAllocator implementation using a spin lock.
  • allocator_api (default): enables the Allocator trait and implements it on all global allocators.

Example

#![no_std]

use core::ptr::NonNull;
use palloc::{GlobalPalloc, SpinPalloc};

// the allocator is initialized using a const empty function, but it is
// not ready yet, we must initialize it first in main.
#[global_allocator]
static mut ALLOCATOR: SpinPalloc = SpinPalloc::empty();

fn main() {
    // First of all we must define the bounds of our heap. Check
    // Palloc or GlobalPalloc documentation for informations.

    // Heap starting address
    let heap_start = 0x8000 as *mut u8;
    // Heap size
    let heap_size = 0xF000;

    // accessing statics is an unsafe operation
    // so it must be sorrounded by an unsafe block
    unsafe { ALLOCATOR.init(NonNull::new(heap_start).unwrap(), heap_size) };

    // we can now use the heap!
    // ...
}

Documentation

Everything you need to know is already written in the rustdocs. Click on the badge under the readme's title or click here to read the full documentation.

You might also like...
Key-value store for embedded systems, for raw NOR flash, using an LSM-Tree.

ekv Key-value store for embedded systems, for raw NOR flash, using an LSM-Tree. Features None yet TODO Everything Minimum supported Rust version (MSRV

A collection of comparison-benchmarks for Nova & related Proving systems

Nova benchmarks Here's a list of some of the benchmarks we've been taking to better understand how Nova performs vs other proof systems. Live version:

Stack heap flexible string designed to improve performance for Rust

flexible-string A stack heap flexible string designed to improve performance. FlexibleString was first implemented in spdlog-rs crate, which improved

A set of Zero Knowledge modules, written in Rust and designed to be used in other system programming environments.

Zerokit A set of Zero Knowledge modules, written in Rust and designed to be used in other system programming environments. Initial scope Focus on RLN

The utility is designed to check the availability of peers and automatically update them in the Yggdrasil configuration file, as well as using the admin API - addPeer method.

Yggrasil network peers checker / updater The utility is designed to check the availability of peers and automatically update them in the Yggdrasil con

An actors library for Rust and Tokio designed to work with async / await message handlers out of the box.

Akt An actors framework for Rust and Tokio. It is heavily inspired by Actix and right now it has very similar look and feel. The main difference is th

A special rope, designed to work with any data type that is not String

AnyRope AnyRope is an arbitrary data type rope for Rust, designed for similar operations that a rope would do, but targeted at data types that are not

The Fast Vector Similarity Library is designed to provide efficient computation of various similarity measures between vectors.
The Fast Vector Similarity Library is designed to provide efficient computation of various similarity measures between vectors.

Fast Vector Similarity Library Introduction The Fast Vector Similarity Library is designed to provide efficient computation of various similarity meas

CloudLLM is a Rust library designed to seamlessly bridge applications with remote Language Learning Models (LLMs) across various platforms.
CloudLLM is a Rust library designed to seamlessly bridge applications with remote Language Learning Models (LLMs) across various platforms.

CloudLLM CloudLLM is a Rust library designed to seamlessly bridge applications with remote Language Learning Models (LLMs) across various platforms. W

Comments
  • Allocation ignores alignment requirements

    Allocation ignores alignment requirements

    When implementing the GlobalAlloc::alloc function for SpinPalloc and UnsafeCellPalloc, the alignment requirement of the provided layout is ignored. This can lead to undefined behaviour.

    opened by MaderNoob 1
Owner
Pietro
@stack_smash on telegram.
Pietro
A tree-backed slab allocator

beton A tree-backed slab allocator API Docs | Releases | Contributing Installation $ cargo add beton Memory Safety This crate uses unsafe operations i

Yosh 6 Sep 12, 2023
Learn Rust by writing Entirely Too Many linked lists

Learn Rust by writing Entirely Too Many Linked Lists Read the pretty version at https://rust-unofficial.github.io/too-many-lists/. Building Building r

null 2.4k Jan 3, 2023
Linked Atomic Random Insert Vector: a thread-safe, self-memory-managed vector with no guaranteed sequential insert.

Linked Atomic Random Insert Vector Lariv is a thread-safe, self-memory-managed vector with no guaranteed sequential insert. It internally uses a linke

Guillem Jara 8 Feb 1, 2023
A community curated list of Rust Language streamers

Awesome Rust Streaming This is a community curated list of livestreams about the programming language Rust. Don't see a stream that you like? Feel fre

James Munns 587 Dec 26, 2022
List of Rust books

Rust Books Books Starter Books Advanced Books Resources Books Starter Books The Rust Programming Language Free Welcome! This book will teach you about

Spiros Gerokostas 2.2k Jan 9, 2023
A curated list of Rust code and resources.

Awesome Rust A curated list of Rust code and resources. If you want to contribute, please read this. Table of contents Applications Audio and Music Cr

null 31.2k Dec 30, 2022
List public items (public API) of Rust library crates. Enables diffing public API between releases.

cargo wrapper for this library You probably want the cargo wrapper to this library. See https://github.com/Enselic/cargo-public-items. public_items Li

Martin Nordholts 20 Dec 26, 2022
A recommender systems framework for Rust

Quackin Release the quackin! ?? Quackin is a recommender systems framework written in Rust. This is a young project, which means two things: There wil

Christopher Vittal 8 Dec 8, 2021
High Assurance Rust - A free book about developing secure and robust systems software.

High Assurance Rust - A free book about developing secure and robust systems software.

Tiemoko Ballo 1.1k Jan 9, 2023
A type-safe, high speed programming language for scalable systems

A type-safe, high speed programming language for scalable systems! (featuring a cheesy logo!) note: the compiler is unfinished and probably buggy. if

Hail 0 Sep 14, 2022