Add wasm_runtime_unregister_natives (#1647)

Allow to unregister (or unload) the previously registered native libs,
so that no need to restart the whole engine by using
`wasm_runtime_destroy/wasm_runtime_init`.
This commit is contained in:
YAMAMOTO Takashi
2022-10-28 12:03:39 +09:00
committed by GitHub
parent bc58778c34
commit 77ff7daaf4
6 changed files with 96 additions and 4 deletions

View File

@ -356,6 +356,26 @@ wasm_native_register_natives_raw(const char *module_name,
true);
}
bool
wasm_native_unregister_natives(const char *module_name,
NativeSymbol *native_symbols)
{
NativeSymbolsNode **prevp;
NativeSymbolsNode *node;
prevp = &g_native_symbols_list;
while ((node = *prevp) != NULL) {
if (node->native_symbols == native_symbols
&& !strcmp(node->module_name, module_name)) {
*prevp = node->next;
wasm_runtime_free(node);
return true;
}
prevp = &node->next;
}
return false;
}
bool
wasm_native_init()
{