sunchao commented on a change in pull request #1449:
URL: https://github.com/apache/arrow-rs/pull/1449#discussion_r827673771
##########
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:
Suppose we stick with one API, I think we need to make sure the exporter
always free up the struct memory after the exported array is imported. Maybe we
can ask clients to check the `release` field and only free the memory when
`release` is not set. Nevertheless this will be a behavior change and should be
properly documented.
For instance, for those who are using `ArrowArray::into_raw`, they need to
remember releasing the struct memory, e.g.:
```rust
let (array, schema) = ArrowArray::into_raw(src_array);
// we can't do it here since otherwise the import will fail
// unsafe {
// let _ = (Arc::from_raw(array), Arc::from_raw(schema));
// }
// `array` and `schema` are imported and used
// now release the struct memory
unsafe {
let _ = (Arc::from_raw(array), Arc::from_raw(schema));
}
```
--
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]