MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / dealloc

Method dealloc

crates/core/src/slab.rs:431–447  ·  view source on GitHub ↗
(&mut self, id: Id)

Source from the content-addressed store, hash-verified

429 /// deallocate an arbitrary value.
430 #[inline]
431 pub fn dealloc(&mut self, id: Id) -> T {
432 let entry = core::mem::replace(
433 self.entries
434 .get_mut(id.0.index())
435 .expect("id from a different slab"),
436 Entry::Free { next_free: None },
437 );
438 match entry {
439 Entry::Free { .. } => panic!("attempt to deallocate an entry that is already vacant"),
440 Entry::Occupied(value) => {
441 let next_free = core::mem::replace(&mut self.free, Some(id.0));
442 self.entries[id.0.index()] = Entry::Free { next_free };
443 self.len -= 1;
444 value
445 }
446 }
447 }
448
449 /// Iterate over all values currently allocated within this `Slab`.
450 ///

Callers 7

dropMethod · 0.45
insertMethod · 0.45
removeMethod · 0.45
nextMethod · 0.45
or_insert_with_keyMethod · 0.45
remove_entryMethod · 0.45
insert_entryMethod · 0.45

Calls 4

replaceFunction · 0.50
expectMethod · 0.45
get_mutMethod · 0.45
indexMethod · 0.45

Tested by

no test coverage detected