Use pointer::add instead of pointer::offset with a cast.

This commit is contained in:
Dan Gohman
2019-11-08 16:22:41 -08:00
parent 39b0d670c5
commit 5b0031ece8
3 changed files with 5 additions and 10 deletions

View File

@@ -58,7 +58,7 @@ unsafe extern "C" fn stub_fn(vmctx: *mut VMContext, call_id: u32, values_vec: *m
Ok(()) => {
for i in 0..returns_len {
// TODO check signature.returns[i].value_type ?
returns[i].write_value_to(values_vec.offset(i as isize));
returns[i].write_value_to(values_vec.add(i));
}
0
}

View File

@@ -460,13 +460,13 @@ pub unsafe extern "C" fn wasm_func_call(
let func = (*func).func.borrow();
let mut params = Vec::with_capacity(func.param_arity());
for i in 0..func.param_arity() {
let val = &(*args.offset(i as isize));
let val = &(*args.add(i));
params.push(val.val());
}
match func.call(&params) {
Ok(out) => {
for i in 0..func.result_arity() {
let val = &mut (*results.offset(i as isize));
let val = &mut (*results.add(i));
*val = wasm_val_t::from_val(&out[i]);
}
ptr::null_mut()
@@ -666,7 +666,7 @@ pub unsafe extern "C" fn wasm_instance_new(
let store = &(*store).store;
let mut externs: Vec<Extern> = Vec::with_capacity((*module).imports.len());
for i in 0..(*module).imports.len() {
let import = *imports.offset(i as isize);
let import = *imports.add(i);
externs.push((*import).ext.clone());
}
let module = &(*module).module;

View File

@@ -71,12 +71,7 @@ unsafe extern "C" fn stub_fn(vmctx: *mut VMContext, call_id: u32, values_vec: *m
}
result.clone_ref(py)
};
write_value_to(
py,
values_vec.offset(i as isize),
signature.returns[i].value_type,
val,
);
write_value_to(py, values_vec.add(i), signature.returns[i].value_type, val);
}
}