From 104919eb79ccd9013dd5b7e39d9db7788e1971c7 Mon Sep 17 00:00:00 2001 From: Peter Huene Date: Tue, 25 Feb 2020 12:58:38 -0800 Subject: [PATCH] Remove Drop impl for `wasi_instance_t`. --- crates/c-api/src/wasi.rs | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/crates/c-api/src/wasi.rs b/crates/c-api/src/wasi.rs index b709750e8e..b03fe2b08d 100644 --- a/crates/c-api/src/wasi.rs +++ b/crates/c-api/src/wasi.rs @@ -192,15 +192,7 @@ pub unsafe extern "C" fn wasi_config_preopen_dir( #[repr(C)] pub struct wasi_instance_t { wasi: Wasi, - export_cache: HashMap, -} - -impl Drop for wasi_instance_t { - fn drop(&mut self) { - for v in self.export_cache.values() { - drop(unsafe { Box::from_raw(*v) }); - } - } + export_cache: HashMap>, } #[no_mangle] @@ -260,14 +252,14 @@ pub unsafe extern "C" fn wasi_instance_bind_import( return std::ptr::null_mut(); } - *(*instance) + &**(*instance) .export_cache .entry(name.to_string()) .or_insert_with(|| { - Box::into_raw(Box::new(wasm_extern_t { + Box::new(wasm_extern_t { which: ExternHost::Func(HostRef::new(export.clone())), - })) - }) + }) + }) as *const wasm_extern_t } None => std::ptr::null_mut(), }