mirror of
https://github.com/mii443/wasmer.git
synced 2025-12-13 13:58:38 +00:00
feat(c-api) Implement wasm_$name_vec_t::is_uninitialized().
This commit is contained in:
@@ -56,22 +56,24 @@ 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.data.is_null() {
|
if self.is_unitialized() {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
Some(::std::slice::from_raw_parts(self.data, self.size))
|
Some(::std::slice::from_raw_parts(self.data, self.size))
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
impl [<wasm_ $name _vec_t>] {
|
|
||||||
pub unsafe fn into_slice_mut(&self) -> Option<&mut [[<wasm_ $name _t>]]>{
|
pub unsafe fn into_slice_mut(&self) -> Option<&mut [[<wasm_ $name _t>]]>{
|
||||||
if self.data.is_null() {
|
if self.is_unitialized() {
|
||||||
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 {
|
||||||
|
self.data.is_null()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: investigate possible memory leak on `init` (owned pointer)
|
// TODO: investigate possible memory leak on `init` (owned pointer)
|
||||||
|
|||||||
Reference in New Issue
Block a user