Browse Source

Fix ownership in *_vec_new functions in the C API

These functions are specified to take ownership of the objects in the
given slice, not clone them.
pull/3582/head
Amanieu d'Antras 3 years ago
parent
commit
ce67e7fcd1
  1. 4
      crates/c-api/src/vec.rs

4
crates/c-api/src/vec.rs

@ -120,8 +120,8 @@ macro_rules! declare_vecs {
size: usize,
ptr: *const $elem_ty,
) {
let slice = slice::from_raw_parts(ptr, size);
out.set_buffer(slice.to_vec());
let vec = (0..size).map(|i| ptr.add(i).read()).collect();
out.set_buffer(vec);
}
#[no_mangle]

Loading…
Cancel
Save