fix(c-api) Allow finalizer to be NULL.

This commit is contained in:
Ivan Enderlin
2020-11-16 14:43:26 +01:00
parent d6af40bdd5
commit 287084aa3e

View File

@@ -7,6 +7,7 @@ use std::ffi::c_void;
use std::sync::Arc;
use wasmer::{Function, Instance, RuntimeError, Val};
#[derive(Debug)]
#[allow(non_camel_case_types)]
pub struct wasm_func_t {
pub(crate) inner: Function,
@@ -91,12 +92,11 @@ pub unsafe extern "C" fn wasm_func_new_with_env(
function_type: Option<&wasm_functype_t>,
callback: Option<wasm_func_callback_with_env_t>,
env: *mut c_void,
finalizer: Option<wasm_env_finalizer_t>,
finalizer: wasm_env_finalizer_t,
) -> Option<Box<wasm_func_t>> {
let store = store?;
let function_type = function_type?;
let callback = callback?;
let finalizer = finalizer?;
let func_sig = &function_type.inner().function_type;
let num_rets = func_sig.results().len();