Skip to content

Commit 1293771

Browse files
committed
Use std::mem::size_of instead of core::mem::size_of
Allocation APIs were previously only allowed access to core. Now that they have access to libstd their usages should be replaced.
1 parent e41b73e commit 1293771

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/alloc.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99

1010
use std::{
1111
alloc::{Alloc, AllocErr, GlobalAlloc, Layout},
12+
mem::size_of,
1213
ptr::NonNull,
1314
sync::atomic::{AtomicBool, Ordering},
14-
mem::size_of,
1515
};
1616

1717
static SIZE_ALLOC_INFO: usize = (1024 * 1024) * 2; // 2MiB
@@ -178,7 +178,7 @@ impl<'a> Iterator for AllocListIterMut<'a> {
178178
return None;
179179
}
180180

181-
let ptr = self.alloc_list.start as usize + (self.idx * core::mem::size_of::<Block>());
181+
let ptr = self.alloc_list.start as usize + (self.idx * size_of::<Block>());
182182
self.idx += 1;
183183

184184
unsafe { Some(&mut *(ptr as *mut Block)) }
@@ -191,7 +191,7 @@ impl<'a> Iterator for AllocListIter<'a> {
191191
fn next(&mut self) -> Option<&'a Block> {
192192
// It's UB to call `.add` on a pointer past its allocation bounds, so we
193193
// need to check that it's within range before turning it into a pointer
194-
if self.idx * core::mem::size_of::<Block>() >= SIZE_ALLOC_INFO {
194+
if self.idx * size_of::<Block>() >= SIZE_ALLOC_INFO {
195195
return None;
196196
}
197197

@@ -201,7 +201,7 @@ impl<'a> Iterator for AllocListIter<'a> {
201201
return None;
202202
}
203203

204-
let ptr = self.alloc_list.start as usize + (self.idx * core::mem::size_of::<Block>());
204+
let ptr = self.alloc_list.start as usize + (self.idx * size_of::<Block>());
205205
self.idx += 1;
206206

207207
let entry = unsafe { &*(ptr as *const Block) };

0 commit comments

Comments
 (0)