MCPcopy Create free account
hub / github.com/bluejekyll/wasmtime-java / alloc

Method alloc

wasmtime-jni/src/ty/wasm_alloc.rs:139–156  ·  view source on GitHub ↗
(
        &self,
        store: &mut Store<JavaState>,
    )

Source from the content-addressed store, hash-verified

137 }
138
139 pub fn alloc<T: Sized>(
140 &self,
141 store: &mut Store<JavaState>,
142 ) -> Result<WasmSliceWrapper<'_>, Error> {
143 let wasm_slice = unsafe { self.alloc_size(mem::size_of::<T>(), &mut *store)? };
144
145 // zero out the memory...
146 for b in unsafe { wasm_slice.as_mut(&mut *store) } {
147 *b = 0;
148 }
149
150 debug!(
151 "stored {} at {:x?}",
152 std::any::type_name::<T>(),
153 wasm_slice.wasm_slice().ptr()
154 );
155 Ok(wasm_slice)
156 }
157
158 #[allow(clippy::mut_from_ref)]
159 pub unsafe fn obj_as_mut<T: Sized, S: AsContextMut>(&self, ptr: i32, store: S) -> &mut T {

Callers

nothing calls this directly

Calls 2

alloc_sizeMethod · 0.80
as_mutMethod · 0.45

Tested by

no test coverage detected