@@ -12,7 +12,7 @@ use core::alloc::{GlobalAlloc, Layout};
12
12
use core:: cell:: RefCell ;
13
13
use core:: ptr:: { self , NonNull } ;
14
14
15
- use cortex_m :: interrupt :: Mutex ;
15
+ use critical_section :: Mutex ;
16
16
use linked_list_allocator:: Heap ;
17
17
18
18
pub struct CortexMHeap {
@@ -54,25 +54,25 @@ impl CortexMHeap {
54
54
/// - This function must be called exactly ONCE.
55
55
/// - `size > 0`
56
56
pub unsafe fn init ( & self , start_addr : usize , size : usize ) {
57
- cortex_m :: interrupt :: free ( |cs| {
57
+ critical_section :: with ( |cs| {
58
58
self . heap . borrow ( cs) . borrow_mut ( ) . init ( start_addr, size) ;
59
59
} ) ;
60
60
}
61
61
62
62
/// Returns an estimate of the amount of bytes in use.
63
63
pub fn used ( & self ) -> usize {
64
- cortex_m :: interrupt :: free ( |cs| self . heap . borrow ( cs) . borrow_mut ( ) . used ( ) )
64
+ critical_section :: with ( |cs| self . heap . borrow ( cs) . borrow_mut ( ) . used ( ) )
65
65
}
66
66
67
67
/// Returns an estimate of the amount of bytes available.
68
68
pub fn free ( & self ) -> usize {
69
- cortex_m :: interrupt :: free ( |cs| self . heap . borrow ( cs) . borrow_mut ( ) . free ( ) )
69
+ critical_section :: with ( |cs| self . heap . borrow ( cs) . borrow_mut ( ) . free ( ) )
70
70
}
71
71
}
72
72
73
73
unsafe impl GlobalAlloc for CortexMHeap {
74
74
unsafe fn alloc ( & self , layout : Layout ) -> * mut u8 {
75
- cortex_m :: interrupt :: free ( |cs| {
75
+ critical_section :: with ( |cs| {
76
76
self . heap
77
77
. borrow ( cs)
78
78
. borrow_mut ( )
@@ -83,7 +83,7 @@ unsafe impl GlobalAlloc for CortexMHeap {
83
83
}
84
84
85
85
unsafe fn dealloc ( & self , ptr : * mut u8 , layout : Layout ) {
86
- cortex_m :: interrupt :: free ( |cs| {
86
+ critical_section :: with ( |cs| {
87
87
self . heap
88
88
. borrow ( cs)
89
89
. borrow_mut ( )
0 commit comments