Skip to content

Commit

Permalink
Use std::ptr::replace
Browse files Browse the repository at this point in the history
  • Loading branch information
kylebarron committed Nov 13, 2023
1 parent 05ea67d commit e7ed58d
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions arrow/src/pyarrow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -263,10 +263,12 @@ impl FromPyArrow for ArrayData {
validate_pycapsule(array_capsule, "arrow_array")?;

let schema_ptr = unsafe { schema_capsule.reference::<FFI_ArrowSchema>() };
let array_ptr = array_capsule.pointer() as *mut FFI_ArrowArray;
let array_mut = unsafe { array_ptr.as_mut() };

let array = std::mem::replace(array_mut.unwrap(), FFI_ArrowArray::empty());
let array = unsafe {
std::ptr::replace(
array_capsule.pointer() as *mut FFI_ArrowArray,
FFI_ArrowArray::empty(),
)
};
return ffi::from_ffi(array, schema_ptr).map_err(to_py_err);
}

Expand Down

0 comments on commit e7ed58d

Please sign in to comment.