fn new_allocation_area(&mut self) -> AllocationArea {
        let mmap_pages = self.get_amortized_chunk_size_in_pages();
        let mmap_size = mmap_pages * PAGE_SIZE;
        let mmap_file_offset = self.file_len;

        self.file_len += mmap_size as i64;
        // SAFETY: The file descriptor is valid.  We need `cvt_r` to handle `EINTR`.
        cvt_r(|| unsafe { ftruncate64(self.file_descriptor, self.file_len) }).unwrap_or_else(
            |err| {
                panic!(
                    "MmapPageAllocator failed to grow the memory file #{} to {} bytes: {}",
                    self.file_descriptor, self.file_len, err
                )
            },
        );

        // 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 {} while allocating a new memory block: {}",
                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,
        });

        let start = mmap_ptr;
        // SAFETY: We memory-mapped exactly `mmap_size` bytes, so `end` points one byte
        // after the last byte of the chunk.
        let end = unsafe { mmap_ptr.add(mmap_size) };
        AllocationArea {
            start,
            end,
            offset: mmap_file_offset,
        }
    }
// The implementation of the slow path of allocation.
The implementation of the slow path of allocation.
The implementation of the slow path of allocation .
fn new_allocation_area(&mut self) -> AllocationArea {
        let mmap_pages = self.get_amortized_chunk_size_in_pages();
        let mmap_size = mmap_pages * PAGE_SIZE;
        let mmap_file_offset = self.file_len;
        self.file_len += mmap_size as i64;
        // SAFETY: The file descriptor is valid.  We need `cvt_r` to handle `EINTR`.
        cvt_r(|| unsafe { ftruncate64(self.file_descriptor, self.file_len) }).unwrap_or_else(
            |err| {
                panic!(
                    "MmapPageAllocator failed to grow the memory file #{} to {} bytes: {}",
                    self.file_descriptor, self.file_len, err
                )
            },
        );
        // 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 {} while allocating a new memory block: {}",
                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,
        });
        let start = mmap_ptr;
        // SAFETY: We memory-mapped exactly `mmap_size` bytes, so `end` points one byte
        // after the last byte of the chunk.
        let end = unsafe { mmap_ptr.add(mmap_size) };
        AllocationArea {
            start,
            end,
            offset: mmap_file_offset,
        }
    }
fn new_allocation_area ( & mut self ) -> AllocationArea { let mmap_pages = self . get_amortized_chunk_size_in_pages ( ) ; let mmap_size = mmap_pages * PAGE_SIZE ; let mmap_file_offset = self . file_len ; self . file_len += mmap_size as i64 ; // SAFETY: The file descriptor is valid.  We need `cvt_r` to handle `EINTR`. cvt_r ( | | unsafe { ftruncate64 ( self . file_descriptor , self . file_len ) } ) . unwrap_or_else ( | err | { panic ! ( " " self file_descriptor self file_len err ) } , ) ; // 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 , } ) ; let start = mmap_ptr ; // SAFETY: We memory-mapped exactly `mmap_size` bytes, so `end` points one byte // after the last byte of the chunk. let end = unsafe { mmap_ptr . add ( mmap_size ) } ; AllocationArea { start , end , offset : mmap_file_offset , } }
The implementation of the slow path of allocation.
The implementation of the slow path of allocation .
&mut self
&mut self