Use .map()
This commit is contained in:
@@ -42,20 +42,15 @@ impl PtrLen {
|
|||||||
fn with_size(size: usize) -> io::Result<Self> {
|
fn with_size(size: usize) -> io::Result<Self> {
|
||||||
let page_size = region::page::size();
|
let page_size = region::page::size();
|
||||||
let alloc_size = round_up_to_page_size(size, page_size);
|
let alloc_size = round_up_to_page_size(size, page_size);
|
||||||
let map = MmapMut::map_anon(alloc_size);
|
MmapMut::map_anon(alloc_size).map(|mut mmap| {
|
||||||
|
|
||||||
match map {
|
|
||||||
Ok(mut map) => {
|
|
||||||
// The order here is important; we assign the pointer first to get
|
// The order here is important; we assign the pointer first to get
|
||||||
// around compile time borrow errors.
|
// around compile time borrow errors.
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
ptr: map.as_mut_ptr(),
|
ptr: mmap.as_mut_ptr(),
|
||||||
map: Some(map),
|
map: Some(mmap),
|
||||||
len: alloc_size,
|
len: alloc_size,
|
||||||
})
|
})
|
||||||
}
|
})
|
||||||
Err(e) => Err(e),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(all(not(target_os = "windows"), not(feature = "selinux-fix")))]
|
#[cfg(all(not(target_os = "windows"), not(feature = "selinux-fix")))]
|
||||||
|
|||||||
Reference in New Issue
Block a user