mirror of
https://github.com/mii443/wasmer.git
synced 2025-12-09 14:18:20 +00:00
feat(c-api) Implement wasm_$name_vec_t::into_slice_mut.
This commit is contained in:
@@ -64,6 +64,16 @@ macro_rules! wasm_declare_vec {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl [<wasm_ $name _vec_t>] {
|
||||||
|
pub unsafe fn into_slice_mut(&self) -> Option<&mut [[<wasm_ $name _t>]]>{
|
||||||
|
if self.data.is_null() {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
|
||||||
|
Some(::std::slice::from_raw_parts_mut(self.data, self.size))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: investigate possible memory leak on `init` (owned pointer)
|
// TODO: investigate possible memory leak on `init` (owned pointer)
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn [<wasm_ $name _vec_new>](out: *mut [<wasm_ $name _vec_t>], length: usize, init: *mut [<wasm_ $name _t>]) {
|
pub unsafe extern "C" fn [<wasm_ $name _vec_new>](out: *mut [<wasm_ $name _vec_t>], length: usize, init: *mut [<wasm_ $name _t>]) {
|
||||||
|
|||||||
Reference in New Issue
Block a user