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

Method free

cranelift/entity/src/list.rs:217–230  ·  view source on GitHub ↗

Free a storage block with a size given by `sclass`. This must be a block that was previously allocated by `alloc()` with the same size class.

(&mut self, block: usize, sclass: SizeClass)

Source from the content-addressed store, hash-verified

215 ///
216 /// This must be a block that was previously allocated by `alloc()` with the same size class.
217 fn free(&mut self, block: usize, sclass: SizeClass) {
218 let sclass = sclass as usize;
219
220 // Make sure we have a free-list head for `sclass`.
221 if self.free.len() <= sclass {
222 self.free.resize(sclass + 1, 0);
223 }
224
225 // Make sure the length field is cleared.
226 self.data[block] = T::new(0);
227 // Insert the block on the free list which is a single linked list.
228 self.data[block + 1] = T::new(self.free[sclass]);
229 self.free[sclass] = block + 1
230 }
231
232 /// Returns two mutable slices representing the two requested blocks.
233 ///

Callers 3

reallocMethod · 0.45
clearMethod · 0.45
block_allocatorFunction · 0.45

Calls 3

newFunction · 0.50
lenMethod · 0.45
resizeMethod · 0.45

Tested by 1

block_allocatorFunction · 0.36