@@ -12,7 +12,7 @@ use core::alloc::{GlobalAlloc, Layout};
1212use core:: cell:: RefCell ;
1313use core:: ptr:: { self , NonNull } ;
1414
15- use cortex_m :: interrupt :: Mutex ;
15+ use critical_section :: Mutex ;
1616use linked_list_allocator:: Heap ;
1717
1818pub struct CortexMHeap {
@@ -54,7 +54,7 @@ impl CortexMHeap {
5454 /// - This function must be called exactly ONCE.
5555 /// - `size > 0`
5656 pub unsafe fn init ( & self , start_addr : usize , size : usize ) {
57- cortex_m :: interrupt :: free ( |cs| {
57+ critical_section :: with ( |cs| {
5858 self . heap
5959 . borrow ( cs)
6060 . borrow_mut ( )
@@ -64,18 +64,18 @@ impl CortexMHeap {
6464
6565 /// Returns an estimate of the amount of bytes in use.
6666 pub fn used ( & self ) -> usize {
67- cortex_m :: interrupt :: free ( |cs| self . heap . borrow ( cs) . borrow_mut ( ) . used ( ) )
67+ critical_section :: with ( |cs| self . heap . borrow ( cs) . borrow_mut ( ) . used ( ) )
6868 }
6969
7070 /// Returns an estimate of the amount of bytes available.
7171 pub fn free ( & self ) -> usize {
72- cortex_m :: interrupt :: free ( |cs| self . heap . borrow ( cs) . borrow_mut ( ) . free ( ) )
72+ critical_section :: with ( |cs| self . heap . borrow ( cs) . borrow_mut ( ) . free ( ) )
7373 }
7474}
7575
7676unsafe impl GlobalAlloc for CortexMHeap {
7777 unsafe fn alloc ( & self , layout : Layout ) -> * mut u8 {
78- cortex_m :: interrupt :: free ( |cs| {
78+ critical_section :: with ( |cs| {
7979 self . heap
8080 . borrow ( cs)
8181 . borrow_mut ( )
@@ -86,7 +86,7 @@ unsafe impl GlobalAlloc for CortexMHeap {
8686 }
8787
8888 unsafe fn dealloc ( & self , ptr : * mut u8 , layout : Layout ) {
89- cortex_m :: interrupt :: free ( |cs| {
89+ critical_section :: with ( |cs| {
9090 self . heap
9191 . borrow ( cs)
9292 . borrow_mut ( )
0 commit comments