Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test+doc(c-api) Fix vecs that must be boxed vecs + don't transmute uninitialized boxed vecs #1949

Merged
merged 18 commits into from
Dec 18, 2020
Merged
Changes from 1 commit
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
a4effaa
test+doc(c-api) Continue to improve test coverage of the C API.
Hywan Dec 17, 2020
e10ad51
fix(c-api) Fix how `wasm_functype_t` is implemented.
Hywan Dec 17, 2020
75ceb0d
fix(c-api) Fix how `wasm_globaltype_t` is implemented.
Hywan Dec 17, 2020
a3c7a2d
fix(c-api) Fix how `wasm_memorytype_t` is implemented.
Hywan Dec 17, 2020
a0c34fe
fix(c-api) Fix how `wasm_tabletype_t` is implemented.
Hywan Dec 17, 2020
4abf6f8
fix(c-api) Fix how `wasm_frame_t` is implemented.
Hywan Dec 17, 2020
43026e6
feat(c-api) Implement `From<&[T]> for wasm_$name_vec_t` for boxed vec.
Hywan Dec 17, 2020
940dea7
feat(c-api) Simplify code by using new conversion implementations.
Hywan Dec 17, 2020
8aa0822
feat(c-api) `wasm_$name_vec_delete` checks the vec is initialized.
Hywan Dec 17, 2020
96169de
test+doc(c-api) Improve test coverage for the `macros` module, and im…
Hywan Dec 17, 2020
eb03f18
Merge branch 'master' into doc-c-api-2
Hywan Dec 17, 2020
2853bd4
doc(changelog) Add #1949.
Hywan Dec 17, 2020
272b9d1
Merge branch 'master' into doc-c-api-2
Hywan Dec 17, 2020
51fe219
feat(c-api) `wasm_$name_vec_delete` for boxed vec now takes an `Optio…
Hywan Dec 18, 2020
a68a1e6
feat(c-api) Transmute boxed vecs to `Vec<Option<Box<T>>>` when deleting.
Hywan Dec 18, 2020
40fa9c0
fix(c-api) UPdate `wasm_functype_new` according to previous commit.
Hywan Dec 18, 2020
2ca30fe
fix(c-api) Ensure that uninitialized boxed vec are zeroed.
Hywan Dec 18, 2020
b9afb6e
fix(c-api) Remove `Box` from `wasm_functype_new`.
Hywan Dec 18, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix(c-api) UPdate wasm_functype_new according to previous commit.
  • Loading branch information
Hywan committed Dec 18, 2020
commit 40fa9c08c76b9bc0b4b3d1a1261cb163ad6e8f9b
12 changes: 8 additions & 4 deletions lib/c-api/src/wasm_c_api/types/function.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use super::{wasm_externtype_t, wasm_valtype_vec_delete, wasm_valtype_vec_t, WasmExternType};
use std::mem;
use wasmer::{ExternType, FunctionType, ValType};

#[derive(Debug)]
@@ -58,8 +59,8 @@ pub unsafe extern "C" fn wasm_functype_new(
params: Option<Box<wasm_valtype_vec_t>>,
results: Option<Box<wasm_valtype_vec_t>>,
) -> Option<Box<wasm_functype_t>> {
let params = params?;
let results = results?;
let mut params = params?;
let mut results = results?;

let params_as_valtype: Vec<ValType> = params
.into_slice()?
@@ -72,8 +73,11 @@ pub unsafe extern "C" fn wasm_functype_new(
.map(|val| val.as_ref().into())
.collect::<Vec<_>>();

wasm_valtype_vec_delete(Box::into_raw(params));
wasm_valtype_vec_delete(Box::into_raw(results));
wasm_valtype_vec_delete(Some(params.as_mut()));
wasm_valtype_vec_delete(Some(results.as_mut()));

mem::forget(params);
mem::forget(results);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally, we'd have Drop implemented and it'd do this for us


Some(Box::new(wasm_functype_t::new(FunctionType::new(
params_as_valtype,