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

Method grow_to

tests/all/memory_creator.rs:66–78  ·  view source on GitHub ↗
(&mut self, new_size: usize)

Source from the content-addressed store, hash-verified

64 }
65
66 fn grow_to(&mut self, new_size: usize) -> wasmtime::Result<()> {
67 println!("grow to {new_size:x}");
68 let delta = new_size - self.used_wasm_bytes;
69 unsafe {
70 let start = (self.mem as *mut u8).add(self.used_wasm_bytes) as _;
71 mprotect(start, delta, MprotectFlags::READ | MprotectFlags::WRITE)
72 .expect("mprotect failed");
73 }
74
75 *self.glob_bytes_counter.lock().unwrap() += delta;
76 self.used_wasm_bytes = new_size;
77 Ok(())
78 }
79
80 fn as_ptr(&self) -> *mut u8 {
81 self.mem as *mut u8

Callers

nothing calls this directly

Calls 5

OkFunction · 0.85
addMethod · 0.45
expectMethod · 0.45
unwrapMethod · 0.45
lockMethod · 0.45

Tested by

no test coverage detected