File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change 7
7
//! extern crate alloc_cortex_m;
8
8
//! extern crate collections;
9
9
//!
10
- //! use alloc_cortex_m::HEAP ;
10
+ //! use alloc_cortex_m::init as alloc_init ;
11
11
//! use collections::Vec;
12
12
//!
13
13
//! #[no_mangle]
14
14
//! pub fn main() -> ! {
15
15
//! // Initialize the heap BEFORE you use the allocator
16
- //! unsafe { HEAP.init (0x2000_0000, 1024) }
16
+ //! unsafe { alloc_init (0x2000_0000, 1024) }
17
17
//!
18
18
//! let mut xs = Vec::new();
19
19
//! xs.push(1);
@@ -66,6 +66,14 @@ impl Heap {
66
66
}
67
67
}
68
68
69
+ /// Init function
70
+ pub unsafe fn alloc_init ( start_addr : * mut usize , end_addr : * mut usize ) {
71
+ let start = start_addr as usize ;
72
+ let end = end_addr as usize ;
73
+ let size = ( end - start) - 1 ;
74
+ HEAP . lock ( |heap| heap. init ( start, size) ) ;
75
+ }
76
+
69
77
// Rust allocator interface
70
78
71
79
#[ doc( hidden) ]
You can’t perform that action at this time.
0 commit comments