File tree Expand file tree Collapse file tree 2 files changed +36
-1
lines changed Expand file tree Collapse file tree 2 files changed +36
-1
lines changed Original file line number Diff line number Diff line change 2424 with :
2525 targets : ${{ matrix.target }}
2626 toolchain : ${{ matrix.toolchain }}
27- - run : cargo check --target=${{ matrix.target }} --examples
27+ - run : cargo check --target=${{ matrix.target }} --example global_alloc
2828 - if : ${{ matrix.toolchain == 'nightly' }}
2929 run : cargo check --target=${{ matrix.target }} --examples --all-features
3030
Original file line number Diff line number Diff line change 1+ #![ feature( allocator_api) ]
2+ #![ no_std]
3+ #![ no_main]
4+
5+ extern crate alloc;
6+
7+ use alloc:: vec:: Vec ;
8+ use core:: mem:: MaybeUninit ;
9+ use core:: panic:: PanicInfo ;
10+ use cortex_m_rt:: entry;
11+ use embedded_alloc:: Heap ;
12+
13+ // This is not used, but as of 2023-10-29 allocator_api cannot be used without
14+ // a global heap
15+ #[ global_allocator]
16+ static HEAP : Heap = Heap :: empty ( ) ;
17+
18+ #[ entry]
19+ fn main ( ) -> ! {
20+ const HEAP_SIZE : usize = 16 ;
21+ static mut HEAP_MEM : [ MaybeUninit < u8 > ; HEAP_SIZE ] = [ MaybeUninit :: uninit ( ) ; HEAP_SIZE ] ;
22+ let heap: Heap = Heap :: empty ( ) ;
23+ unsafe { heap. init ( HEAP_MEM . as_ptr ( ) as usize , HEAP_SIZE ) }
24+
25+ let mut xs = Vec :: new_in ( heap) ;
26+ xs. push ( 1 ) ;
27+
28+ #[ allow( clippy:: empty_loop) ]
29+ loop { /* .. */ }
30+ }
31+
32+ #[ panic_handler]
33+ fn panic ( _: & PanicInfo ) -> ! {
34+ loop { }
35+ }
You can’t perform that action at this time.
0 commit comments