mirror of
https://github.com/mii443/wasmer.git
synced 2025-12-08 13:48:26 +00:00
feat(c-api) Allow extern types to own data.
We have known memory leaks with extern types. The idea is to change the code so that extern types can hold/own data. This patch does that. A `wasm_externtype_t` holds a `WasmExternType` enum. This enum owns sibling types such as `WasmFunctionType`, `WasmGlobalType`, `WasmTableType` and `WasmMemoryType`. It is those structures that ows the extern types data, like `params` and `results` as `wasm_valtype_vec_t` for `WasmFunctionType`. That way, for example, `wasm_functype_t` can return a pointer to these vec which it owns. A `wasm_externtype_t` continues to be transmuted to `wasm_functype_t` etc. Nothing changes on that side.
This commit is contained in:
@@ -17,6 +17,7 @@ macro_rules! wasm_declare_vec_inner {
|
||||
macro_rules! wasm_declare_vec {
|
||||
($name:ident) => {
|
||||
paste::item! {
|
||||
#[derive(Debug)]
|
||||
#[repr(C)]
|
||||
pub struct [<wasm_ $name _vec_t>] {
|
||||
pub size: usize,
|
||||
@@ -108,6 +109,7 @@ macro_rules! wasm_declare_vec {
|
||||
macro_rules! wasm_declare_boxed_vec {
|
||||
($name:ident) => {
|
||||
paste::item! {
|
||||
#[derive(Debug)]
|
||||
#[repr(C)]
|
||||
pub struct [<wasm_ $name _vec_t>] {
|
||||
pub size: usize,
|
||||
|
||||
Reference in New Issue
Block a user