You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by su...@apache.org on 2022/02/20 18:26:08 UTC

[arrow-rs] branch master updated: Don't use Arc::from_raw when importing ArrowArray and ArrowSchema (#1334)

This is an automated email from the ASF dual-hosted git repository.

sunchao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow-rs.git


The following commit(s) were added to refs/heads/master by this push:
     new f84c436  Don't use Arc::from_raw when importing ArrowArray and ArrowSchema (#1334)
f84c436 is described below

commit f84c4364d5e1cd5879f5ef9cc6441cdf233df8c3
Author: Liang-Chi Hsieh <vi...@gmail.com>
AuthorDate: Sun Feb 20 10:26:03 2022 -0800

    Don't use Arc::from_raw when importing ArrowArray and ArrowSchema (#1334)
---
 arrow/src/ffi.rs | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/arrow/src/ffi.rs b/arrow/src/ffi.rs
index 5a066cc..b7a22de 100644
--- a/arrow/src/ffi.rs
+++ b/arrow/src/ffi.rs
@@ -107,7 +107,7 @@ bitflags! {
 /// See <https://arrow.apache.org/docs/format/CDataInterface.html#structure-definitions>
 /// 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<usize> {
 /// See <https://arrow.apache.org/docs/format/CDataInterface.html#structure-definitions>
 /// 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),
         })
     }