// Free the memory of given range and punch a hole in the backing file.
// Preconditions:
// - the range is mapped as shared and writable.
// - the range is not empty.
Free the memory of given range and punch a hole in the backing file.
Preconditions:
the range is mapped as shared and writable.
the range is not empty.
Free the memory of given range and punch a hole in the backing file . Preconditions : the range is mapped as shared and writable . the range is not empty .
unsafe fn madvise_remove(start_ptr: *mut u8, end_ptr: *mut u8) {
    let ptr = start_ptr as *mut c_void;
    let size = end_ptr.offset_from(start_ptr);
    assert!(size > 0);
    // SAFETY: the range is mapped as shared and writable by precondition.
    madvise(ptr, size as usize, MmapAdvise::MADV_REMOVE).unwrap_or_else(|err| {
        panic!(
            "Failed to madvise a page range {:?}..{:?}:
        {}",
            start_ptr, end_ptr, err
        )
    });
}
unsafe fn madvise_remove ( start_ptr : * mut u8 , end_ptr : * mut u8 ) { let ptr = start_ptr as * mut c_void ; let size = end_ptr . offset_from ( start_ptr ) ; assert ! ( size 0 ) ; // SAFETY: the range is mapped as shared and writable by precondition. madvise ( ptr , size as usize , MmapAdvise :: MADV_REMOVE ) . unwrap_or_else ( | err | { panic ! ( " " start_ptr end_ptr err ) } ) ; }
Free the memory of given range and punch a hole in the backing file.
Free the memory of given range and punch a hole in the backing file .
start_ptr
*mut u8
end_ptr
*mut u8