wasmtime-c-api: Make wasm_table_set *not* take ownership of its reference

Same for `wasm_table_grow` and `wasm_table_new` and their `init` values.
This commit is contained in:
Nick Fitzgerald
2020-07-10 12:03:03 -07:00
parent d07fdca73a
commit 89603bc6b3
4 changed files with 22 additions and 26 deletions

View File

@@ -30,17 +30,6 @@ pub(crate) enum WasmRefInner {
wasmtime_c_api_macros::declare_own!(wasm_ref_t);
pub(crate) fn ref_into_val(r: Option<Box<wasm_ref_t>>) -> Option<Val> {
// Let callers decide whether to treat this as a null `funcref` or a
// null `externref`.
let r = r?;
Some(match r.r {
WasmRefInner::ExternRef(x) => Val::ExternRef(Some(x)),
WasmRefInner::FuncRef(f) => Val::FuncRef(Some(f)),
})
}
pub(crate) fn ref_to_val(r: &wasm_ref_t) -> Val {
match &r.r {
WasmRefInner::ExternRef(x) => Val::ExternRef(Some(x.clone())),