fn new_root(max_size: usize) -> Result<(Arc<zx::Vmo>, Node), Error> {
        let mut size = max(constants::MINIMUM_VMO_SIZE_BYTES, max_size);
        // If the size is not a multiple of 4096, round up.
        if size % constants::MINIMUM_VMO_SIZE_BYTES != 0 {
            size =
                (1 + size / constants::MINIMUM_VMO_SIZE_BYTES) * constants::MINIMUM_VMO_SIZE_BYTES;
        }
        let (mapping, vmo) = Mapping::allocate_with_name(size, "InspectHeap")
            .map_err(|status| Error::AllocateVmo(status))?;
        let vmo = Arc::new(vmo);
        let heap = Heap::new(Arc::new(mapping)).map_err(|e| Error::CreateHeap(Box::new(e)))?;
        let state =
            State::create(heap, vmo.clone()).map_err(|e| Error::CreateState(Box::new(e)))?;
        Ok((vmo, Node::new_root(state)))
    }
/// Allocates a new VMO and initializes it.
Allocates a new VMO and initializes it.
Allocates a new VMO and initializes it .
fn new_root(max_size: usize) -> Result<(Arc<zx::Vmo>, Node), Error> {
        let mut size = max(constants::MINIMUM_VMO_SIZE_BYTES, max_size);
        // If the size is not a multiple of 4096, round up.
        if size % constants::MINIMUM_VMO_SIZE_BYTES != 0 {
            size =
                (1 + size / constants::MINIMUM_VMO_SIZE_BYTES) * constants::MINIMUM_VMO_SIZE_BYTES;
        }
        let (mapping, vmo) = Mapping::allocate_with_name(size, "InspectHeap")
            .map_err(|status| Error::AllocateVmo(status))?;
        let vmo = Arc::new(vmo);
        let heap = Heap::new(Arc::new(mapping)).map_err(|e| Error::CreateHeap(Box::new(e)))?;
        let state =
            State::create(heap, vmo.clone()).map_err(|e| Error::CreateState(Box::new(e)))?;
        Ok((vmo, Node::new_root(state)))
    }
fn new_root ( max_size : usize ) -> Result < ( Arc < zx :: Vmo > , Node ) , Error > { let mut size = max ( constants :: MINIMUM_VMO_SIZE_BYTES , max_size ) ; // If the size is not a multiple of 4096, round up. if size % constants :: MINIMUM_VMO_SIZE_BYTES != 0 { size = ( 1 + size / constants :: MINIMUM_VMO_SIZE_BYTES ) * constants :: MINIMUM_VMO_SIZE_BYTES ; } let ( mapping , vmo ) = Mapping :: allocate_with_name ( size , " " ) . map_err ( | status | Error :: AllocateVmo ( status ) ) ? ; let vmo = Arc :: new ( vmo ) ; let heap = Heap :: new ( Arc :: new ( mapping ) ) . map_err ( | e | Error :: CreateHeap ( Box :: new ( e ) ) ) ? ; let state = State :: create ( heap , vmo . clone ( ) ) . map_err ( | e | Error :: CreateState ( Box :: new ( e ) ) ) ? ; Ok ( ( vmo , Node :: new_root ( state ) ) ) }
Allocates a new VMO and initializes it.
Allocates a new VMO and initializes it .
max_size
usize
max_size
usize