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

Function wasm_global_new

crates/c-api/src/global.rs:35–49  ·  view source on GitHub ↗
(
    store: &mut wasm_store_t,
    gt: &wasm_globaltype_t,
    val: &wasm_val_t,
)

Source from the content-addressed store, hash-verified

33
34#[unsafe(no_mangle)]
35pub unsafe extern "C" fn wasm_global_new(
36 store: &mut wasm_store_t,
37 gt: &wasm_globaltype_t,
38 val: &wasm_val_t,
39) -> Option<Box<wasm_global_t>> {
40 match Global::new(store.store.context_mut(), gt.ty().ty.clone(), val.val()) {
41 Ok(global) => Some(Box::new(wasm_global_t {
42 ext: wasm_extern_t {
43 store: store.store.clone(),
44 which: global.into(),
45 },
46 })),
47 Err(_) => None,
48 }
49}
50
51#[unsafe(no_mangle)]
52pub extern "C" fn wasm_global_as_extern(g: &mut wasm_global_t) -> &mut wasm_extern_t {

Callers

nothing calls this directly

Calls 5

context_mutMethod · 0.80
valMethod · 0.80
newFunction · 0.50
cloneMethod · 0.45
tyMethod · 0.45

Tested by

no test coverage detected