Function sparse_mmap::try_write_bytes

source ·
pub unsafe fn try_write_bytes<T>(
    dest: *mut T,
    val: u8,
    count: usize,
) -> Result<(), MemoryError>
Expand description

Writes count bytes of the value val to dest. Fails on access violation/SIGSEGV. Note that on case of failure, some of the bytes (even partial elements) may already have been written.

This also fails if initialize_try_copy has not been called.

§Safety

This routine is safe to use if the memory pointed to by dest is being concurrently mutated.

WARNING: This routine should only be used when you know that dest is valid, reserved addresses but you do not know if they are mapped with the appropriate protection. For example, this routine is useful if dest is a sparse mapping where some pages are mapped with PAGE_NOACCESS/PROT_NONE, and some are mapped with PAGE_READWRITE/PROT_WRITE.