Skip to content
This repository has been archived by the owner on Feb 18, 2024. It is now read-only.

Removed un-needed unsafe #225

Merged
merged 1 commit into from
Jul 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 5 additions & 11 deletions src/array/binary/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,11 @@ use super::BinaryArray;

unsafe impl<O: Offset> ToFfi for BinaryArray<O> {
fn buffers(&self) -> Vec<Option<std::ptr::NonNull<u8>>> {
unsafe {
vec![
self.validity.as_ref().map(|x| x.as_ptr()),
Some(std::ptr::NonNull::new_unchecked(
self.offsets.as_ptr() as *mut u8
)),
Some(std::ptr::NonNull::new_unchecked(
self.values.as_ptr() as *mut u8
)),
]
}
vec![
self.validity.as_ref().map(|x| x.as_ptr()),
std::ptr::NonNull::new(self.offsets.as_ptr() as *mut u8),
std::ptr::NonNull::new(self.values.as_ptr() as *mut u8),
]
}

#[inline]
Expand Down
12 changes: 4 additions & 8 deletions src/array/fixed_size_binary/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,14 +133,10 @@ impl std::fmt::Display for FixedSizeBinaryArray {

unsafe impl ToFfi for FixedSizeBinaryArray {
fn buffers(&self) -> Vec<Option<std::ptr::NonNull<u8>>> {
unsafe {
vec![
self.validity.as_ref().map(|x| x.as_ptr()),
Some(std::ptr::NonNull::new_unchecked(
self.values.as_ptr() as *mut u8
)),
]
}
vec![
self.validity.as_ref().map(|x| x.as_ptr()),
std::ptr::NonNull::new(self.values.as_ptr() as *mut u8),
]
}

fn offset(&self) -> usize {
Expand Down
12 changes: 4 additions & 8 deletions src/array/list/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,10 @@ use super::ListArray;

unsafe impl<O: Offset> ToFfi for ListArray<O> {
fn buffers(&self) -> Vec<Option<std::ptr::NonNull<u8>>> {
unsafe {
vec![
self.validity.as_ref().map(|x| x.as_ptr()),
Some(std::ptr::NonNull::new_unchecked(
self.offsets.as_ptr() as *mut u8
)),
]
}
vec![
self.validity.as_ref().map(|x| x.as_ptr()),
std::ptr::NonNull::new(self.offsets.as_ptr() as *mut u8),
]
}

fn offset(&self) -> usize {
Expand Down
12 changes: 4 additions & 8 deletions src/array/primitive/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,10 @@ use super::PrimitiveArray;

unsafe impl<T: NativeType> ToFfi for PrimitiveArray<T> {
fn buffers(&self) -> Vec<Option<std::ptr::NonNull<u8>>> {
unsafe {
vec![
self.validity.as_ref().map(|x| x.as_ptr()),
Some(std::ptr::NonNull::new_unchecked(
self.values.as_ptr() as *mut u8
)),
]
}
vec![
self.validity.as_ref().map(|x| x.as_ptr()),
std::ptr::NonNull::new(self.values.as_ptr() as *mut u8),
]
}

#[inline]
Expand Down
16 changes: 5 additions & 11 deletions src/array/utf8/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,11 @@ use super::Utf8Array;

unsafe impl<O: Offset> ToFfi for Utf8Array<O> {
fn buffers(&self) -> Vec<Option<std::ptr::NonNull<u8>>> {
unsafe {
vec![
self.validity.as_ref().map(|x| x.as_ptr()),
Some(std::ptr::NonNull::new_unchecked(
self.offsets.as_ptr() as *mut u8
)),
Some(std::ptr::NonNull::new_unchecked(
self.values.as_ptr() as *mut u8
)),
]
}
vec![
self.validity.as_ref().map(|x| x.as_ptr()),
std::ptr::NonNull::new(self.offsets.as_ptr() as *mut u8),
std::ptr::NonNull::new(self.values.as_ptr() as *mut u8),
]
}

fn offset(&self) -> usize {
Expand Down