@@ -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,7 +54,7 @@ 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
59
59
. borrow ( cs)
60
60
. borrow_mut ( )
@@ -64,18 +64,18 @@ impl CortexMHeap {
64
64
65
65
/// Returns an estimate of the amount of bytes in use.
66
66
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 ( ) )
68
68
}
69
69
70
70
/// Returns an estimate of the amount of bytes available.
71
71
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 ( ) )
73
73
}
74
74
}
75
75
76
76
unsafe impl GlobalAlloc for CortexMHeap {
77
77
unsafe fn alloc ( & self , layout : Layout ) -> * mut u8 {
78
- cortex_m :: interrupt :: free ( |cs| {
78
+ critical_section :: with ( |cs| {
79
79
self . heap
80
80
. borrow ( cs)
81
81
. borrow_mut ( )
@@ -86,7 +86,7 @@ unsafe impl GlobalAlloc for CortexMHeap {
86
86
}
87
87
88
88
unsafe fn dealloc ( & self , ptr : * mut u8 , layout : Layout ) {
89
- cortex_m :: interrupt :: free ( |cs| {
89
+ critical_section :: with ( |cs| {
90
90
self . heap
91
91
. borrow ( cs)
92
92
. borrow_mut ( )
0 commit comments