// Ensures that that last chunk of the file up to the given length is
// memory-mapped to allow deserialization of pages.
Ensures that that last chunk of the file up to the given length is
memory-mapped to allow deserialization of pages.
Ensures that that last chunk of the file up to the given length is memory - mapped to allow deserialization of pages .
fn grow_for_deserialization(&mut self, file_len: FileOffset) {
        if file_len <= self.file_len {
            return;
        }
        let mmap_size = (file_len - self.file_len) as usize;
        let mmap_file_offset = self.file_len;
        self.file_len = file_len;
        // The mapping is read/write because freeing of pages uses `madvise()` with
        // `MADV_REMOVE`, which requires writable mapping.
        // SAFETY: The parameters are valid.
        let mmap_ptr = unsafe {
            mmap(
                std::ptr::null_mut(),
                mmap_size,
                ProtFlags::PROT_READ | ProtFlags::PROT_WRITE,
                MapFlags::MAP_SHARED,
                self.file_descriptor,
                mmap_file_offset,
            )
        }
        .unwrap_or_else(|err| {
            panic!(
                "MmapPageAllocator failed to mmap {} bytes to memory file #{} \
                         at offset {} for deserialization: {}",
                mmap_size, self.file_descriptor, mmap_file_offset, err,
            )
        }) as *mut u8;
        self.chunks.push(Chunk {
            ptr: mmap_ptr,
            size: mmap_size,
            offset: mmap_file_offset,
        });
    }
fn grow_for_deserialization ( & mut self , file_len : FileOffset ) { if file_len <= self . file_len { return ; } let mmap_size = ( file_len - self . file_len ) as usize ; let mmap_file_offset = self . file_len ; self . file_len = file_len ; // The mapping is read/write because freeing of pages uses `madvise()` with // `MADV_REMOVE`, which requires writable mapping. // SAFETY: The parameters are valid. let mmap_ptr = unsafe { mmap ( std :: ptr :: null_mut ( ) , mmap_size , ProtFlags :: PROT_READ | ProtFlags :: PROT_WRITE , MapFlags :: MAP_SHARED , self . file_descriptor , mmap_file_offset , ) } . unwrap_or_else ( | err | { panic ! ( " \
 " mmap_size self file_descriptor mmap_file_offset err ) } ) as * mut u8 ; self . chunks . push ( Chunk { ptr : mmap_ptr , size : mmap_size , offset : mmap_file_offset , } ) ; }
Ensures that that last chunk of the file up to the given length is
memory-mapped to allow deserialization of pages.
Ensures that that last chunk of the file up to the given length is memory - mapped to allow deserialization of pages .
&mut self
file_len
FileOffset