pitrou commented on code in PR #5070:
URL: https://github.com/apache/arrow-rs/pull/5070#discussion_r1391390448
##########
arrow-schema/src/ffi.rs:
##########
@@ -351,6 +355,9 @@ impl Drop for FFI_ArrowSchema {
}
}
+unsafe impl Send for FFI_ArrowSchema {}
+unsafe impl Sync for FFI_ArrowSchema {}
Review Comment:
Not a Rust programmer, but it seems you should do something like this:
```rust
fn destroy_schema_capsule(val: *mut FFI_ArrowSchema, context: *mut c_void) {
let boxed_schema = unsafe { *Box::from_raw(val) };
// Will release boxed schema and heap-deallocate it
}
// Import the field into a heap-allocated FFI_ArrowSchema
let ffi_schema = FFI_ArrowSchema::try_from(&*field).unwrap();
let boxed_ffi_schema = Box::<FFI_ArrowSchema>::new();
std::mem::replace(&*boxed_ffi_schema, ffi_schema);
let schema_capsule_name = CString::new("arrow_schema").unwrap();
Python::with_gil(|py| {
let capsule = PyCapsule::new_with_destructor(
py,
boxed_ffi_schema.into_raw(),
Some(schema_capsule_name),
destroy_schema_capsule,
)
.unwrap();
});
```
##########
arrow-schema/src/ffi.rs:
##########
@@ -351,6 +355,9 @@ impl Drop for FFI_ArrowSchema {
}
}
+unsafe impl Send for FFI_ArrowSchema {}
+unsafe impl Sync for FFI_ArrowSchema {}
Review Comment:
(this would probably be simpler if there was a
`FFI_ArrowSchema::try_import_from` or even a `FFI_ArrowSchema` constructor from
a Field)
--
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]