You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "wjones127 (via GitHub)" <gi...@apache.org> on 2023/05/23 00:07:44 UTC

[GitHub] [arrow-rs] wjones127 commented on a diff in pull request #4232: feat(api!): make ArrowArrayStreamReader Send

wjones127 commented on code in PR #4232:
URL: https://github.com/apache/arrow-rs/pull/4232#discussion_r1201317777


##########
arrow/src/ffi_stream.rs:
##########
@@ -231,8 +227,7 @@ impl ExportedArrayStream {
                     let struct_array = StructArray::from(batch);
                     let array = FFI_ArrowArray::new(&struct_array.to_data());
 
-                    unsafe { std::ptr::copy(addr_of!(array), out, 1) };
-                    std::mem::forget(array);
+                    unsafe { std::ptr::write_unaligned(out, array) };

Review Comment:
   This is a good question. However, the docs for `write_unaligned` say that `src` is guaranteed not to be dropped:
   
   https://doc.rust-lang.org/std/ptr/fn.write_unaligned.html
   
   Internally, it's calling `intrinsics::forget()`. So I think this is sound.
   https://doc.rust-lang.org/src/core/ptr/mod.rs.html#1447



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org