Skip to content

Commit

Permalink
chore(c-api) Use wasm_$name_vec_t::is_uninitialized().
Browse files Browse the repository at this point in the history
  • Loading branch information
Hywan committed Oct 30, 2020
1 parent 77be104 commit d2a5b8e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/c-api/src/wasm_c_api/externals/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ pub unsafe extern "C" fn wasm_func_call(
.expect("Results conversion failed");

// `results` is an uninitialized vector. Set a new value.
if results.size == 0 || results.data.is_null() {
if results.is_uninitialized() {
*results = vals.into();
}
// `results` is an initialized but empty vector. Fill it
Expand Down
8 changes: 4 additions & 4 deletions lib/c-api/src/wasm_c_api/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,22 +56,22 @@ macro_rules! wasm_declare_vec {

impl [<wasm_ $name _vec_t>] {
pub unsafe fn into_slice(&self) -> Option<&[[<wasm_ $name _t>]]>{
if self.is_unitialized() {
if self.is_uninitialized() {
return None;
}

Some(::std::slice::from_raw_parts(self.data, self.size))
}

pub unsafe fn into_slice_mut(&self) -> Option<&mut [[<wasm_ $name _t>]]>{
if self.is_unitialized() {
pub unsafe fn into_slice_mut(&mut self) -> Option<&mut [[<wasm_ $name _t>]]>{
if self.is_uninitialized() {
return None;
}

Some(::std::slice::from_raw_parts_mut(self.data, self.size))
}

pub fn is_unitialized(&self) -> bool {
pub fn is_uninitialized(&self) -> bool {
self.data.is_null()
}
}
Expand Down

0 comments on commit d2a5b8e

Please sign in to comment.