kylebarron commented on code in PR #5070:
URL: https://github.com/apache/arrow-rs/pull/5070#discussion_r1391272641


##########
arrow-data/src/ffi.rs:
##########
@@ -66,8 +66,12 @@ impl Drop for FFI_ArrowArray {
 unsafe impl Send for FFI_ArrowArray {}
 unsafe impl Sync for FFI_ArrowArray {}
 
-// callback used to drop [FFI_ArrowArray] when it is exported
-unsafe extern "C" fn release_array(array: *mut FFI_ArrowArray) {
+/// callback used to drop [FFI_ArrowArray] when it is exported
+///
+/// # Safety
+///
+/// Must be passed a valid [FFI_ArrowArray].
+pub unsafe extern "C" fn release_array(array: *mut FFI_ArrowArray) {

Review Comment:
   The motivation for exporting this was to enable creating new PyCapsules from 
rust with a destructor that releases the array, but it looks like it should be 
possible to manually call `drop` without exporting the underlying function:
   
   ```rs
   fn pycapsule_array_destructor(ffi_array: FFI_ArrowArray, _capsule_context: 
*mut c_void) {
       drop(ffi_array)
   }
   
   let ffi_array = FFI_ArrowArray::new(...);
   let array_capsule_name = CString::new("arrow_array").unwrap();
   
   Python::with_gil(|py| {
       let capsule = PyCapsule::new_with_destructor(
           py,
           ffi_array,
           Some(array_capsule_name),
           pycapsule_array_destructor,
       )
       .unwrap();
   });
   ```



-- 
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-unsubscr...@arrow.apache.org

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

Reply via email to