Function wasmer_c_api::wasm_c_api::module::wasm_module_validate
source · #[no_mangle]
pub unsafe extern "C" fn wasm_module_validate(
store: Option<&mut wasm_store_t>,
bytes: Option<&wasm_byte_vec_t>,
) -> bool
Expand description
Validates a new WebAssembly module given the configuration in the store.
This validation is normally pretty fast and checks the enabled WebAssembly features in the store engine to assure deterministic validation of the module.
§Example
int main() {
// Create the engine and the store.
wasm_engine_t* engine = wasm_engine_new();
wasm_store_t* store = wasm_store_new(engine);
// Create a WebAssembly module from a WAT definition.
wasm_byte_vec_t wat;
wasmer_byte_vec_new_from_string(&wat, "(module)");
wasm_byte_vec_t wasm;
wat2wasm(&wat, &wasm);
// Validate that the WebAssembly module is correct.
assert(wasm_module_validate(store, &wasm));
// Free everything.
wasm_byte_vec_delete(&wasm);
wasm_byte_vec_delete(&wat);
wasm_store_delete(store);
wasm_engine_delete(engine);
return 0;
}