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


##########
arrow-buffer/src/buffer/mutable.rs:
##########
@@ -455,19 +480,12 @@ impl MutableBuffer {
     }
 }
 
-/// # Safety
-/// `ptr` must be allocated for `old_capacity`.
-#[cold]
-#[allow(deprecated)]
-unsafe fn reallocate(
-    ptr: NonNull<u8>,
-    old_capacity: usize,
-    new_capacity: usize,
-) -> (NonNull<u8>, usize) {
-    let new_capacity = bit_util::round_upto_multiple_of_64(new_capacity);
-    let new_capacity = std::cmp::max(new_capacity, old_capacity * 2);
-    let ptr = alloc::reallocate(ptr, old_capacity, new_capacity);
-    (ptr, new_capacity)
+#[inline]
+fn dangling_ptr() -> NonNull<u8> {
+    // SAFETY: ALIGNMENT is a non-zero usize which is then casted
+    // to a *mut T. Therefore, `ptr` is not null and the conditions for
+    // calling new_unchecked() are respected.
+    unsafe { NonNull::new_unchecked(ALIGNMENT as *mut u8) }

Review Comment:
   This is moved from the alloc module



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