Add validate function and test

This commit is contained in:
Brandon Fish
2019-02-05 00:01:01 -06:00
parent 8d8dea7ec8
commit 309246e0d6
6 changed files with 42 additions and 0 deletions

View File

@ -85,6 +85,17 @@ pub struct wasmer_limits_t {
pub max: uint32_t,
}
#[allow(clippy::cast_ptr_alignment)]
#[no_mangle]
pub unsafe extern "C" fn wasmer_validate(wasm_bytes: *mut uint8_t, wasm_bytes_len: uint32_t) -> bool {
if wasm_bytes.is_null() {
return false;
}
let bytes: &[u8] =
unsafe { ::std::slice::from_raw_parts_mut(wasm_bytes, wasm_bytes_len as usize) };
wasmer_runtime_core::validate(bytes)
}
#[no_mangle]
pub extern "C" fn wasmer_import_object_new() -> *mut wasmer_import_object_t {
Box::into_raw(Box::new(ImportObject::new())) as *mut wasmer_import_object_t