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.
This commit is contained in:
Amanieu d'Antras
2021-12-02 11:53:04 +00:00
parent 6d61c1578f
commit ce67e7fcd1

View File

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