Skip to content

Commit 8437c09

Browse files
authored
Merge pull request #102 from Riceman2000/master
Change to &raw
2 parents dd4391d + 20d9db5 commit 8437c09

File tree

5 files changed

+9
-14
lines changed

5 files changed

+9
-14
lines changed

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ Starting with Rust 1.68, this crate can be used as a global allocator on stable
2222

2323
extern crate alloc;
2424

25-
use core::ptr::addr_of_mut;
2625
use cortex_m_rt::entry;
2726
use embedded_alloc::LlffHeap as Heap;
2827

@@ -36,7 +35,7 @@ fn main() -> ! {
3635
use core::mem::MaybeUninit;
3736
const HEAP_SIZE: usize = 1024;
3837
static mut HEAP_MEM: [MaybeUninit<u8>; HEAP_SIZE] = [MaybeUninit::uninit(); HEAP_SIZE];
39-
unsafe { HEAP.init(addr_of_mut!(HEAP_MEM) as usize, HEAP_SIZE) }
38+
unsafe { HEAP.init(&raw mut HEAP_MEM as usize, HEAP_SIZE) }
4039
}
4140

4241
// now the allocator is ready types like Box, Vec can be used.

examples/allocator_api.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ extern crate alloc;
77
use alloc::vec::Vec;
88
use core::mem::MaybeUninit;
99
use core::panic::PanicInfo;
10-
use core::ptr::addr_of_mut;
1110
use cortex_m_rt::entry;
1211
use embedded_alloc::LlffHeap as Heap;
1312

@@ -21,7 +20,7 @@ fn main() -> ! {
2120
const HEAP_SIZE: usize = 16;
2221
static mut HEAP_MEM: [MaybeUninit<u8>; HEAP_SIZE] = [MaybeUninit::uninit(); HEAP_SIZE];
2322
let heap: Heap = Heap::empty();
24-
unsafe { heap.init(addr_of_mut!(HEAP_MEM) as usize, HEAP_SIZE) }
23+
unsafe { heap.init(&raw mut HEAP_MEM as usize, HEAP_SIZE) }
2524

2625
let mut xs = Vec::new_in(heap);
2726
xs.push(1);

examples/global_alloc.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ extern crate alloc;
55

66
use alloc::vec::Vec;
77
use core::panic::PanicInfo;
8-
use core::ptr::addr_of_mut;
98
use cortex_m_rt::entry;
109
// Linked-List First Fit Heap allocator (feature = "llff")
1110
use embedded_alloc::LlffHeap as Heap;
@@ -22,7 +21,7 @@ fn main() -> ! {
2221
use core::mem::MaybeUninit;
2322
const HEAP_SIZE: usize = 1024;
2423
static mut HEAP_MEM: [MaybeUninit<u8>; HEAP_SIZE] = [MaybeUninit::uninit(); HEAP_SIZE];
25-
unsafe { HEAP.init(addr_of_mut!(HEAP_MEM) as usize, HEAP_SIZE) }
24+
unsafe { HEAP.init(&raw mut HEAP_MEM as usize, HEAP_SIZE) }
2625
}
2726

2827
let mut xs = Vec::new();

examples/llff_integration_test.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ extern crate panic_semihosting;
2121

2222
use alloc::vec::Vec;
2323
use core::mem::{size_of, MaybeUninit};
24-
use core::ptr::addr_of_mut;
2524
use cortex_m_rt::entry;
2625
use cortex_m_semihosting::{debug, hprintln};
2726
use embedded_alloc::LlffHeap as Heap;
@@ -46,9 +45,9 @@ fn test_global_heap() {
4645
fn test_allocator_api() {
4746
// small local heap
4847
const HEAP_SIZE: usize = 16;
49-
let heap_mem: [MaybeUninit<u8>; HEAP_SIZE] = [MaybeUninit::uninit(); HEAP_SIZE];
48+
let mut heap_mem: [MaybeUninit<u8>; HEAP_SIZE] = [MaybeUninit::uninit(); HEAP_SIZE];
5049
let local_heap: Heap = Heap::empty();
51-
unsafe { local_heap.init(heap_mem.as_ptr() as usize, HEAP_SIZE) }
50+
unsafe { local_heap.init(&raw mut heap_mem as usize, HEAP_SIZE) }
5251

5352
assert_eq!(local_heap.used(), 0);
5453

@@ -67,7 +66,7 @@ fn main() -> ! {
6766
{
6867
const HEAP_SIZE: usize = 1024;
6968
static mut HEAP_MEM: [MaybeUninit<u8>; HEAP_SIZE] = [MaybeUninit::uninit(); HEAP_SIZE];
70-
unsafe { HEAP.init(addr_of_mut!(HEAP_MEM) as usize, HEAP_SIZE) }
69+
unsafe { HEAP.init(&raw mut HEAP_MEM as usize, HEAP_SIZE) }
7170
}
7271

7372
#[allow(clippy::type_complexity)]

examples/tlsf_integration_test.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ extern crate panic_semihosting;
2121

2222
use alloc::collections::LinkedList;
2323
use core::mem::MaybeUninit;
24-
use core::ptr::addr_of_mut;
2524
use cortex_m_rt::entry;
2625
use cortex_m_semihosting::{debug, hprintln};
2726
use embedded_alloc::TlsfHeap as Heap;
@@ -55,9 +54,9 @@ fn test_global_heap() {
5554
fn test_allocator_api() {
5655
// small local heap
5756
const HEAP_SIZE: usize = 256;
58-
let heap_mem: [MaybeUninit<u8>; HEAP_SIZE] = [MaybeUninit::uninit(); HEAP_SIZE];
57+
let mut heap_mem: [MaybeUninit<u8>; HEAP_SIZE] = [MaybeUninit::uninit(); HEAP_SIZE];
5958
let local_heap: Heap = Heap::empty();
60-
unsafe { local_heap.init(heap_mem.as_ptr() as usize, HEAP_SIZE) }
59+
unsafe { local_heap.init(heap_mem.as_mut_ptr() as usize, HEAP_SIZE) }
6160

6261
const ELEMS: usize = 2;
6362

@@ -84,7 +83,7 @@ fn test_allocator_api() {
8483
fn main() -> ! {
8584
{
8685
static mut HEAP_MEM: [MaybeUninit<u8>; HEAP_SIZE] = [MaybeUninit::uninit(); HEAP_SIZE];
87-
unsafe { HEAP.init(addr_of_mut!(HEAP_MEM) as usize, HEAP_SIZE) }
86+
unsafe { HEAP.init(&raw mut HEAP_MEM as usize, HEAP_SIZE) }
8887
}
8988

9089
#[allow(clippy::type_complexity)]

0 commit comments

Comments
 (0)