Skip to content

Commit

Permalink
feat: mprotect NonNull
Browse files Browse the repository at this point in the history
  • Loading branch information
JonathanWoollett-Light committed Nov 12, 2023
1 parent 4f7551b commit a77786e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/sys/mman.rs
Original file line number Diff line number Diff line change
Expand Up @@ -561,19 +561,19 @@ pub unsafe fn madvise(
/// let mut slice: &mut [u8] = unsafe {
/// let mem = mmap_anonymous(None, one_k_non_zero, ProtFlags::PROT_NONE, MapFlags::MAP_PRIVATE)
/// .unwrap();
/// mprotect(mem.as_ptr(), ONE_K, ProtFlags::PROT_READ | ProtFlags::PROT_WRITE).unwrap();
/// mprotect(mem, ONE_K, ProtFlags::PROT_READ | ProtFlags::PROT_WRITE).unwrap();
/// std::slice::from_raw_parts_mut(mem.as_ptr().cast(), ONE_K)
/// };
/// assert_eq!(slice[0], 0x00);
/// slice[0] = 0xFF;
/// assert_eq!(slice[0], 0xFF);
/// ```
pub unsafe fn mprotect(
addr: *mut c_void,
addr: NonNull<c_void>,
length: size_t,
prot: ProtFlags,
) -> Result<()> {
Errno::result(libc::mprotect(addr, length, prot.bits())).map(drop)
Errno::result(libc::mprotect(addr.as_ptr(), length, prot.bits())).map(drop)
}

/// synchronize a mapped region
Expand Down

0 comments on commit a77786e

Please sign in to comment.