Skip to content

Commit

Permalink
0503 (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
peamaeq authored Mar 7, 2024
1 parent b8a5f9c commit 5c27ceb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
12 changes: 4 additions & 8 deletions src/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,11 @@ impl Map {
/// # }
/// ```
pub fn into_map_mut(self) -> ConvertResult<MapMut, Self> {
unsafe {
let (ptr, len) = Size::page().bounds(self.0.ptr, self.0.len);
match protect(ptr, len, Protect::ReadWrite) {
let (ptr, len) = unsafe { Size::page().bounds(self.0.ptr, self.0.len) };
match unsafe { protect(ptr, len, Protect::ReadWrite) }{
Ok(()) => Ok(self.0),
Err(err) => Err((err, self)),
}
}
}

/// Updates the advise for the entire mapped region..
Expand Down Expand Up @@ -292,13 +290,11 @@ impl MapMut {
/// # }
/// ```
pub fn into_map(self) -> ConvertResult<Map, Self> {
unsafe {
let (ptr, len) = Size::page().bounds(self.ptr, self.len);
match protect(ptr, len, Protect::ReadWrite) {
let (ptr, len) = unsafe { Size::page().bounds(self.ptr, self.len) };
match unsafe { protect(ptr, len, Protect::ReadWrite) }{
Ok(()) => Ok(Map(self)),
Err(err) => Err((err, self)),
}
}
}

/// Writes modifications back to the filesystem.
Expand Down
2 changes: 1 addition & 1 deletion src/os/windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ impl Drop for MapHandle {

/// Requests the page size and allocation granularity from the system.
pub fn system_info() -> (u32, u32) {
let mut info = mem::MaybeUninit::<SYSTEM_INFO>::uninit();
let info = unsafe {
let mut info = mem::MaybeUninit::<SYSTEM_INFO>::uninit();
GetSystemInfo(info.as_mut_ptr() as LPSYSTEM_INFO);
info.assume_init()
};
Expand Down

0 comments on commit 5c27ceb

Please sign in to comment.