mirror of
https://github.com/mii443/wasmer.git
synced 2025-12-08 13:48:26 +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>] {
|
||||
pub unsafe fn into_slice(&self) -> Option<&[[<wasm_ $name _t>]]>{
|
||||
if self.data.is_null() {
|
||||
if self.is_unitialized() {
|
||||
return None;
|
||||
}
|
||||
|
||||
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>]]>{
|
||||
if self.data.is_null() {
|
||||
if self.is_unitialized() {
|
||||
return None;
|
||||
}
|
||||
|
||||
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)
|
||||
|
||||
Reference in New Issue
Block a user