esp-idf-alloc 0.1.1

An allocator for the ESP32 based on the ESP-IDF.
Documentation
  • Coverage
  • 0%
    0 out of 2 items documented0 out of 1 items with examples
  • Size
  • Source code size: 18.19 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 723.23 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 8s Average build duration of successful builds.
  • all releases: 8s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • ctron/esp-idf-alloc
    10 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • ctron

Rust allocator backed by ESP-IDF

This is a memory allocator for Rust, backed by the ESP-IDF.

This is intended to be used on an ESP32, linked against the ESP-IDF. For more information see:

Usage

Add the following to your main, application project:

extern crate esp_idf_alloc;

#[global_allocator]
static A: esp_idf_alloc::EspIdfAllocator = esp_idf_alloc::EspIdfAllocator;

Error handler

If you use a custom global allocator in your application, you will also need an error handler.

The following code will use the ESP-IDF abort() method to handle the error:

#![feature(alloc_error_handler)]

use core::alloc::Layout;

extern "C" {
    fn abort() -> !;
}

#[alloc_error_handler]
fn alloc_error(_layout: Layout) -> ! {
    unsafe {
        abort();
    }
}

Using with alloc

Also be sure to link in the alloc create, as you might want this. Add the following to your Xargo.toml:

[target.xtensa-esp32-none-elf.dependencies]

alloc={}