Skip to content

Commit

Permalink
Merge pull request WasmEdge#103 from second-state/fix/clippy_and_maco…
Browse files Browse the repository at this point in the history
…s_panic

Fix/clippy and macos panic
  • Loading branch information
L-jasmine authored May 12, 2024
2 parents b92096a + 5032c80 commit 75ef77b
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 528 deletions.
2 changes: 1 addition & 1 deletion crates/wasmedge-sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ links = "wasmedge"
name = "wasmedge-sys"
readme = "README.md"
repository = "https://github.com/WasmEdge/wasmedge-rust-sdk"
version = "0.18.0"
version = "0.18.1"

[dependencies]
log = "0.4"
Expand Down
11 changes: 9 additions & 2 deletions crates/wasmedge-sys/src/instance/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,21 @@ unsafe extern "C" fn wrap_fn<Data>(
});
let data = &mut *(data as *mut Data);

let input = {
let input = if params.is_null() || param_len == 0 {
vec![]
} else {
let raw_input = unsafe { std::slice::from_raw_parts(params, param_len as usize) };
raw_input.iter().map(|r| (*r).into()).collect::<Vec<_>>()
};

let return_len = return_len as usize;

let raw_returns = unsafe { std::slice::from_raw_parts_mut(returns, return_len) };
let mut empty_return = [];
let raw_returns = if returns.is_null() || return_len == 0 {
&mut empty_return
} else {
unsafe { std::slice::from_raw_parts_mut(returns, return_len) }
};

let real_fn: SyncFn<Data> = std::mem::transmute(key_ptr);

Expand Down
Loading

0 comments on commit 75ef77b

Please sign in to comment.