pub fn deallocate(&mut self, ptr: u32) -> Result<(), UserError> {
		let ptr = ptr - self.ptr_offset;
		if ptr < 8 {
			return Err(UserError("Invalid pointer for deallocation"));
		}

		let list_index = self.get_heap_byte(ptr - 8)
			.map_err(|_| UserError("Unable to access pointer prefix"))? as usize;
		for i in 1..8 {
			let heap_byte = self.get_heap_byte(ptr - i)
				.map_err(|_| UserError("Unable to write single bytes into heap at pointer"))?;
			debug_assert!(heap_byte == 255)
		}
		let tail = self.heads[list_index];
		self.heads[list_index] = ptr - 8;

		let mut slice = self.get_heap_4bytes(ptr - 8)
			.map_err(|_| UserError("Unable to get 4 bytes from heap at pointer prefix"))?;
		FreeingBumpHeapAllocator::write_u32_into_le_bytes(tail, &mut slice);
		self.set_heap_4bytes(ptr - 8, slice)
			.map_err(|_| UserError("Unable to write 4 bytes into heap at pointer prefix"))?;

		let item_size = FreeingBumpHeapAllocator::get_item_size_from_index(list_index);
		self.total_size = self.total_size.checked_sub(item_size as u32 + 8)
			.ok_or_else(|| UserError("Unable to subtract from total heap size without overflow"))?;
		trace!(target: "wasm-heap", "Heap size is {} bytes after deallocation", self.total_size);

		Ok(())
	}
/// Deallocates the space which was allocated for a pointer.
Deallocates the space which was allocated for a pointer.
Deallocates the space which was allocated for a pointer .
pub fn deallocate(&mut self, ptr: u32) -> Result<(), UserError> {
		let ptr = ptr - self.ptr_offset;
		if ptr < 8 {
			return Err(UserError("Invalid pointer for deallocation"));
		}
		let list_index = self.get_heap_byte(ptr - 8)
			.map_err(|_| UserError("Unable to access pointer prefix"))? as usize;
		for i in 1..8 {
			let heap_byte = self.get_heap_byte(ptr - i)
				.map_err(|_| UserError("Unable to write single bytes into heap at pointer"))?;
			debug_assert!(heap_byte == 255)
		}
		let tail = self.heads[list_index];
		self.heads[list_index] = ptr - 8;
		let mut slice = self.get_heap_4bytes(ptr - 8)
			.map_err(|_| UserError("Unable to get 4 bytes from heap at pointer prefix"))?;
		FreeingBumpHeapAllocator::write_u32_into_le_bytes(tail, &mut slice);
		self.set_heap_4bytes(ptr - 8, slice)
			.map_err(|_| UserError("Unable to write 4 bytes into heap at pointer prefix"))?;
		let item_size = FreeingBumpHeapAllocator::get_item_size_from_index(list_index);
		self.total_size = self.total_size.checked_sub(item_size as u32 + 8)
			.ok_or_else(|| UserError("Unable to subtract from total heap size without overflow"))?;
		trace!(target: "wasm-heap", "Heap size is {} bytes after deallocation", self.total_size);
		Ok(())
	}
pub fn deallocate ( & mut self , ptr : u32 ) -> Result < ( ) , UserError > { let ptr = ptr - self . ptr_offset ; if ptr < 8 { return Err ( UserError ( " " ) ) ; } let list_index = self . get_heap_byte ( ptr - 8 ) . map_err ( | _ | UserError ( " " ) ) ? as usize ; for i in 1 .. 8 { let heap_byte = self . get_heap_byte ( ptr - i ) . map_err ( | _ | UserError ( " " ) ) ? ; debug_assert ! ( heap_byte 255 ) } let tail = self . heads [ list_index ] ; self . heads [ list_index ] = ptr - 8 ; let mut slice = self . get_heap_4bytes ( ptr - 8 ) . map_err ( | _ | UserError ( " " ) ) ? ; FreeingBumpHeapAllocator :: write_u32_into_le_bytes ( tail , & mut slice ) ; self . set_heap_4bytes ( ptr - 8 , slice ) . map_err ( | _ | UserError ( " " ) ) ? ; let item_size = FreeingBumpHeapAllocator :: get_item_size_from_index ( list_index ) ; self . total_size = self . total_size . checked_sub ( item_size as u32 + 8 ) . ok_or_else ( | | UserError ( " " ) ) ? ; trace ! ( target " " " " self total_size ) ; Ok ( ( ) ) }
Deallocates the space which was allocated for a pointer.
Deallocates the space which was allocated for a pointer .
&mut self
ptr
u32
&mut self
ptr
u32