wangfenjin commented on a change in pull request #1449:
URL: https://github.com/apache/arrow-rs/pull/1449#discussion_r827670552



##########
File path: arrow/src/ffi.rs
##########
@@ -781,11 +781,19 @@ impl ArrowArray {
                     .to_string(),
             ));
         };
-        let ffi_array = (*array).clone();
-        let ffi_schema = (*schema).clone();
+
+        let array_mut = array as *mut FFI_ArrowArray;
+        let schema_mut = schema as *mut FFI_ArrowSchema;
+
+        let array_data = std::ptr::replace(array_mut, FFI_ArrowArray::empty());

Review comment:
       What about change into_raw() to this:
   ```rust
       /// exports [ArrowArray] to the C Data Interface
       pub unsafe fn into_raw(this: ArrowArray) -> (*const FFI_ArrowArray, 
*const FFI_ArrowSchema) {
           let mut out_schema: *const FFI_ArrowSchema = &mut 
FFI_ArrowSchema::empty();
           let mut out_array: *const FFI_ArrowArray = &mut 
FFI_ArrowArray::empty();
   
           let schema = Arc::into_raw(this.schema);
           let array =  Arc::into_raw(this.array);
           let schema_data: *const FFI_ArrowSchema = std::ptr::replace(&mut 
out_schema as *mut _, schema);
           let array_data: *const FFI_ArrowArray = std::ptr::replace(&mut 
out_array as *mut _, array);
           let _ = Arc::from_raw(schema);
           let _ = Arc::from_raw(array);
   
           (array_data, schema_data)
       }
   ```




-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to