Macro esp_ward::prepare_alloc

source ·
macro_rules! prepare_alloc {
    () => { ... };
}
Expand description

Sets up a global allocator for heap memory, required for the alloc crate functionalities. This is essential for using heap-allocated data structures which are used, for example, for max7219 display. ATTENTION: MAKE SURE to use this prepare_alloc as a first function in your program if you’re using module which utilizes alloc. Modules like this will have a warning that you should use the alloc feature

§Safety

This macro should be called ONCE AND ONLY ONCE during initialization before using any features that require dynamic memory allocation.

Concept is taken from esp-alloc: https://github.com/esp-rs/esp-alloc/tree/main

§Examples

esp_ward::prepare_alloc!();
let v: Vec<u8> = Vec::new(); // Now we can use structs from `alloc`, like `Vec``