feat(c-api) Shrink vector of traps.

Ensure that the size of the vector of the instance's traps equals its
capacity by shrinking it.
This commit is contained in:
Ivan Enderlin
2020-10-27 11:49:01 +01:00
parent 452181326a
commit 4102dcb9ac

View File

@@ -45,6 +45,7 @@ pub unsafe extern "C" fn wasm_instance_new(
let trap: Box<wasm_trap_t> = Box::new(runtime_error.into());
let mut traps: Vec<*mut wasm_trap_t> = Vec::with_capacity(1);
traps.push(Box::into_raw(trap));
traps.shrink_to_fit();
let pointer = traps.as_mut_ptr();
mem::forget(traps);