Add Table grow function

This commit is contained in:
Brandon Fish
2019-02-09 13:58:50 -06:00
parent 4e5e525626
commit 8364c39b4c
4 changed files with 35 additions and 2 deletions

View File

@ -163,6 +163,22 @@ pub unsafe extern "C" fn wasmer_table_new(
wasmer_table_result_t::WASMER_TABLE_OK
}
#[allow(clippy::cast_ptr_alignment)]
#[no_mangle]
pub extern "C" fn wasmer_table_grow(
table: *mut wasmer_table_t,
delta: uint32_t,
) -> wasmer_table_result_t {
let table = unsafe { Box::from_raw(table as *mut Table) };
let maybe_delta = table.grow(delta);
Box::into_raw(table);
if let Some(_delta) = maybe_delta {
wasmer_table_result_t::WASMER_TABLE_OK
} else {
wasmer_table_result_t::WASMER_TABLE_ERROR
}
}
#[allow(clippy::cast_ptr_alignment)]
#[no_mangle]
pub extern "C" fn wasmer_table_length(table: *mut wasmer_table_t) -> uint32_t {