File tree Expand file tree Collapse file tree 2 files changed +8
-7
lines changed Expand file tree Collapse file tree 2 files changed +8
-7
lines changed Original file line number Diff line number Diff line change @@ -16,4 +16,4 @@ version = "0.3.2"
16
16
17
17
[dependencies ]
18
18
cortex-m = " 0.1.5"
19
- linked_list_allocator = " 0.5 .0"
19
+ linked_list_allocator = " 0.6 .0"
Original file line number Diff line number Diff line change @@ -51,7 +51,8 @@ extern crate cortex_m;
51
51
extern crate linked_list_allocator;
52
52
extern crate alloc;
53
53
54
- use alloc:: allocator:: { Alloc , Layout , AllocErr } ;
54
+ use core:: alloc:: { GlobalAlloc , Layout , Opaque } ;
55
+ use core:: ptr:: NonNull ;
55
56
56
57
use linked_list_allocator:: Heap ;
57
58
use cortex_m:: interrupt:: Mutex ;
@@ -100,14 +101,14 @@ impl CortexMHeap {
100
101
}
101
102
}
102
103
103
- unsafe impl < ' a > Alloc for & ' a CortexMHeap {
104
- unsafe fn alloc ( & mut self , layout : Layout ) -> Result < * mut u8 , AllocErr > {
104
+ unsafe impl GlobalAlloc for CortexMHeap {
105
+ unsafe fn alloc ( & self , layout : Layout ) -> * mut Opaque {
105
106
self . heap . lock ( |heap| {
106
107
heap. allocate_first_fit ( layout)
107
- } )
108
+ } ) . ok ( ) . map_or ( 0 as * mut Opaque , |allocation| allocation . as_ptr ( ) )
108
109
}
109
110
110
- unsafe fn dealloc ( & mut self , ptr : * mut u8 , layout : Layout ) {
111
- self . heap . lock ( |heap| heap. deallocate ( ptr, layout) ) ;
111
+ unsafe fn dealloc ( & self , ptr : * mut Opaque , layout : Layout ) {
112
+ self . heap . lock ( |heap| heap. deallocate ( NonNull :: new_unchecked ( ptr) , layout) ) ;
112
113
}
113
114
}
You can’t perform that action at this time.
0 commit comments