We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent caa821e commit a61b645Copy full SHA for a61b645
examples/global_alloc.rs
@@ -16,9 +16,12 @@ static ALLOCATOR: CortexMHeap = CortexMHeap::empty();
16
#[entry]
17
fn main() -> ! {
18
// Initialize the allocator BEFORE you use it
19
- let start = cortex_m_rt::heap_start() as usize;
20
- let size = 1024; // in bytes
21
- unsafe { ALLOCATOR.init(start, size) }
+ {
+ use core::mem::MaybeUninit;
+ const HEAP_SIZE: usize = 1024;
22
+ static mut HEAP: [MaybeUninit<u8>; HEAP_SIZE] = [MaybeUninit::uninit(); HEAP_SIZE];
23
+ unsafe { ALLOCATOR.init((&mut HEAP).as_ptr() as usize, HEAP_SIZE) }
24
+ }
25
26
let mut xs = Vec::new();
27
xs.push(1);
0 commit comments