diff --git a/arrow/src/ffi.rs b/arrow/src/ffi.rs index 5a066ccdea9c..b7a22deab13e 100644 --- a/arrow/src/ffi.rs +++ b/arrow/src/ffi.rs @@ -107,7 +107,7 @@ bitflags! { /// See /// This was created by bindgen #[repr(C)] -#[derive(Debug)] +#[derive(Debug, Clone)] pub struct FFI_ArrowSchema { format: *const c_char, name: *const c_char, @@ -316,7 +316,7 @@ fn bit_width(data_type: &DataType, i: usize) -> Result { /// See /// This was created by bindgen #[repr(C)] -#[derive(Debug)] +#[derive(Debug, Clone)] pub struct FFI_ArrowArray { pub(crate) length: i64, pub(crate) null_count: i64, @@ -721,9 +721,11 @@ impl ArrowArray { .to_string(), )); }; + let ffi_array = (*array).clone(); + let ffi_schema = (*schema).clone(); Ok(Self { - array: Arc::from_raw(array as *mut FFI_ArrowArray), - schema: Arc::from_raw(schema as *mut FFI_ArrowSchema), + array: Arc::new(ffi_array), + schema: Arc::new(ffi_schema), }) }