pub unsafe fn allocate(size: usize, protected: bool) -> MemorySegment {
        let size = MemorySegment::page_aligned_size(size);
        let pointer = mmap(ptr::null_mut(), size as size_t,
            PROT_READ | PROT_WRITE,
            MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);

        if pointer == MAP_FAILED {
            error!("mmap failed");
        } else {
            info!("Allocated {} bytes with mmap", size);
        }

        let mut segment = MemorySegment {
            address: pointer as usize,
            size: size,
            protected: false,
        };

        if protected {
            segment.protect();
        }
        segment
    }
/// Allocates a protected memory segment of at least `size` bytes.
Allocates a protected memory segment of at least `size` bytes.
Allocates a protected memory segment of at least ` size ` bytes .
pub unsafe fn allocate(size: usize, protected: bool) -> MemorySegment {
        let size = MemorySegment::page_aligned_size(size);
        let pointer = mmap(ptr::null_mut(), size as size_t,
            PROT_READ | PROT_WRITE,
            MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
        if pointer == MAP_FAILED {
            error!("mmap failed");
        } else {
            info!("Allocated {} bytes with mmap", size);
        }
        let mut segment = MemorySegment {
            address: pointer as usize,
            size: size,
            protected: false,
        };
        if protected {
            segment.protect();
        }
        segment
    }
pub unsafe fn allocate ( size : usize , protected : bool ) -> MemorySegment { let size = MemorySegment :: page_aligned_size ( size ) ; let pointer = mmap ( ptr :: null_mut ( ) , size as size_t , PROT_READ | PROT_WRITE , MAP_PRIVATE | MAP_ANONYMOUS , - 1 , 0 ) ; if pointer == MAP_FAILED { error ! ( " " ) ; } else { info ! ( " " size ) ; } let mut segment = MemorySegment { address : pointer as usize , size : size , protected : false , } ; if protected { segment . protect ( ) ; } segment }
Allocates a protected memory segment of at least `size` bytes.
Allocates a protected memory segment of at least ` size ` bytes .
size
usize
protected
bool