pub unsafe fn mlock_with(
    ptr: *mut c_void,
    len: usize,
    flags: MlockFlags
) -> Result<()>
Available on crate feature mm only.
Expand description

mlock2(ptr, len, flags)—Lock memory into RAM, with flags.

mlock_with is the same as mlock but adds an additional flags operand.

Safety

This function operates on raw pointers, but it should only be used on memory which the caller owns. Technically, locking memory shouldn’t violate any invariants, but since unlocking it can violate invariants, this function is also unsafe for symmetry.

Some implementations implicitly round the memory region out to the nearest page boundaries, so this function may lock more memory than explicitly requested if the memory isn’t page-aligned.

References