mirror of
https://github.com/mii443/wasmer.git
synced 2025-12-08 13:48:26 +00:00
chore(c-api) Use wasm_$name_vec_t::is_uninitialized().
This commit is contained in:
@@ -167,7 +167,7 @@ pub unsafe extern "C" fn wasm_func_call(
|
|||||||
.expect("Results conversion failed");
|
.expect("Results conversion failed");
|
||||||
|
|
||||||
// `results` is an uninitialized vector. Set a new value.
|
// `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 = vals.into();
|
||||||
}
|
}
|
||||||
// `results` is an initialized but empty vector. Fill it
|
// `results` is an initialized but empty vector. Fill it
|
||||||
|
|||||||
@@ -56,22 +56,22 @@ macro_rules! wasm_declare_vec {
|
|||||||
|
|
||||||
impl [<wasm_ $name _vec_t>] {
|
impl [<wasm_ $name _vec_t>] {
|
||||||
pub unsafe fn into_slice(&self) -> Option<&[[<wasm_ $name _t>]]>{
|
pub unsafe fn into_slice(&self) -> Option<&[[<wasm_ $name _t>]]>{
|
||||||
if self.is_unitialized() {
|
if self.is_uninitialized() {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
Some(::std::slice::from_raw_parts(self.data, self.size))
|
Some(::std::slice::from_raw_parts(self.data, self.size))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub unsafe fn into_slice_mut(&self) -> Option<&mut [[<wasm_ $name _t>]]>{
|
pub unsafe fn into_slice_mut(&mut self) -> Option<&mut [[<wasm_ $name _t>]]>{
|
||||||
if self.is_unitialized() {
|
if self.is_uninitialized() {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
Some(::std::slice::from_raw_parts_mut(self.data, self.size))
|
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()
|
self.data.is_null()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user