tustvold commented on code in PR #3687:
URL: https://github.com/apache/arrow-rs/pull/3687#discussion_r1102615698


##########
arrow/src/ffi.rs:
##########
@@ -592,36 +219,22 @@ unsafe fn create_buffer(
     index: usize,
     len: usize,
 ) -> Option<Buffer> {
-    if array.buffers.is_null() || array.n_buffers == 0 {
+    if array.num_buffers() == 0 {
         return None;
     }
-    let buffers = array.buffers as *mut *const u8;
-
-    assert!(index < array.n_buffers as usize);
-    let ptr = *buffers.add(index);
-
-    NonNull::new(ptr as *mut u8)
+    NonNull::new(array.buffer(index) as _)
         .map(|ptr| Buffer::from_custom_allocation(ptr, len, owner))
 }
 
-fn create_child(
+fn create_child<'a>(

Review Comment:
   This method was actually previously incorrect, as it `coerced` a non-static 
borrow into a static borrow. Fortunately the fix is unobtrusive, and doesn't 
impact the public API



##########
arrow/src/ffi.rs:
##########
@@ -592,36 +219,22 @@ unsafe fn create_buffer(
     index: usize,
     len: usize,
 ) -> Option<Buffer> {
-    if array.buffers.is_null() || array.n_buffers == 0 {
+    if array.num_buffers() == 0 {
         return None;
     }
-    let buffers = array.buffers as *mut *const u8;
-
-    assert!(index < array.n_buffers as usize);
-    let ptr = *buffers.add(index);
-
-    NonNull::new(ptr as *mut u8)
+    NonNull::new(array.buffer(index) as _)
         .map(|ptr| Buffer::from_custom_allocation(ptr, len, owner))
 }
 
-fn create_child(
+fn create_child<'a>(

Review Comment:
   This method was actually previously incorrect, as it "coerced" a non-static 
borrow into a static borrow. Fortunately the fix is unobtrusive, and doesn't 
impact the public API



-- 
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]

Reply via email to