pub fn new_memory(&mut self, initial: u32, maximum: u32) -> Result<u32, UserError> {
		let maximum = match maximum {
			sandbox_primitives::MEM_UNLIMITED => None,
			specified_limit => Some(Pages(specified_limit as usize)),
		};

		let mem =
			MemoryInstance::alloc(
				Pages(initial as usize),
				maximum,
			)
			.map_err(|_| UserError("Sandboxed memory allocation error"))?;

		let mem_idx = self.memories.len();
		self.memories.push(Some(mem));
		Ok(mem_idx as u32)
	}
/// Create a new memory instance and return it's index.
///
/// # Errors
///
/// Returns `Err` if the memory couldn't be created.
/// Typically happens if `initial` is more than `maximum`.
Create a new memory instance and return it's index.
Create a new memory instance and return it ' s index .
pub fn new_memory(&mut self, initial: u32, maximum: u32) -> Result<u32, UserError> {
		let maximum = match maximum {
			sandbox_primitives::MEM_UNLIMITED => None,
			specified_limit => Some(Pages(specified_limit as usize)),
		};
		let mem =
			MemoryInstance::alloc(
				Pages(initial as usize),
				maximum,
			)
			.map_err(|_| UserError("Sandboxed memory allocation error"))?;
		let mem_idx = self.memories.len();
		self.memories.push(Some(mem));
		Ok(mem_idx as u32)
	}
pub fn new_memory ( & mut self , initial : u32 , maximum : u32 ) -> Result < u32 , UserError > { let maximum = match maximum { sandbox_primitives :: MEM_UNLIMITED => None , specified_limit => Some ( Pages ( specified_limit as usize ) ) , } ; let mem = MemoryInstance :: alloc ( Pages ( initial as usize ) , maximum , ) . map_err ( | _ | UserError ( " " ) ) ? ; let mem_idx = self . memories . len ( ) ; self . memories . push ( Some ( mem ) ) ; Ok ( mem_idx as u32 ) }
Create a new memory instance and return it's index.
Create a new memory instance and return it ' s index .
&mut self
initial
u32
maximum
u32
&mut self
initial
u32
maximum
u32
errors
Returns `Err` if the memory couldn't be created.
Typically happens if `initial` is more than `maximum`.
Returns ` Err ` if the memory couldn ' t be created . Typically happens if ` initial ` is more than ` maximum ` .