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

Method alloc_node

cranelift/bforest/src/pool.rs:34–52  ·  view source on GitHub ↗

Allocate a new node containing `data`.

(&mut self, data: NodeData<F>)

Source from the content-addressed store, hash-verified

32
33 /// Allocate a new node containing `data`.
34 pub fn alloc_node(&mut self, data: NodeData<F>) -> Result<Node, OutOfMemory> {
35 debug_assert!(!data.is_free(), "can't allocate free node");
36 match self.freelist {
37 Some(node) => {
38 // Remove this node from the free list.
39 match self.nodes[node] {
40 NodeData::Free { next } => self.freelist = next,
41 _ => panic!("Invalid {node} on free list"),
42 }
43 self.nodes[node] = data;
44 Ok(node)
45 }
46 None => {
47 // The free list is empty. Allocate a new node.
48 self.nodes.try_reserve(1)?;
49 Ok(self.nodes.push(data))
50 }
51 }
52 }
53
54 /// Free a node.
55 pub fn free_node(&mut self, node: Node) {

Callers 5

split_and_insertMethod · 0.80
search_single_leafFunction · 0.80
search_single_innerFunction · 0.80
try_insertMethod · 0.80
try_insertMethod · 0.80

Calls 3

OkFunction · 0.85
try_reserveMethod · 0.80
pushMethod · 0.45

Tested by 2

search_single_leafFunction · 0.64
search_single_innerFunction · 0.64