Skip to content

Commit ce67e7f

Browse files
committed
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.
1 parent 6d61c15 commit ce67e7f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

crates/c-api/src/vec.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,8 @@ macro_rules! declare_vecs {
120120
size: usize,
121121
ptr: *const $elem_ty,
122122
) {
123-
let slice = slice::from_raw_parts(ptr, size);
124-
out.set_buffer(slice.to_vec());
123+
let vec = (0..size).map(|i| ptr.add(i).read()).collect();
124+
out.set_buffer(vec);
125125
}
126126

127127
#[no_mangle]

0 commit comments

Comments
 (0)