Crate mips_mcu_alloc

source ·
Expand description

A heap allocator for microcontollers with MIPS core such as PIC32 controllers

The heap is placed at a location determined by the linker and automatically extended to fullfil allocation requests. Automatic heap extension fails if the heap would collide with the stack.

§Example

#![feature(global_allocator)]
#![feature(alloc_error_handler)]

// Plug in the allocator crate
extern crate alloc;

use alloc::Vec;
use mips_mcu_alloc::MipsMcuHeap;

#[global_allocator]
static ALLOCATOR: MipsMcuHeap = MipsMcuHeap::empty();

#[entry]
fn main() -> ! {
    ALLOCATOR.init();

    let mut xs = Vec::new();
    xs.push(1);

    loop { /* .. */ }
}

#[alloc_error_handler]
fn alloc_error(layout: core::alloc::Layout) -> ! {
    panic!("Cannot allocate heap memory: {:?}", layout);
}

Structs§

Enums§