tustvold commented on code in PR #3289:
URL: https://github.com/apache/arrow-rs/pull/3289#discussion_r1042734587
##########
arrow-buffer/src/alloc/mod.rs:
##########
@@ -28,9 +28,18 @@ mod alignment;
pub use alignment::ALIGNMENT;
+/// Returns an aligned non null pointer similar to [`NonNull::dangling`]
+///
+/// Note that the pointer value may potentially represent a valid pointer,
which means
+/// this must not be used as a "not yet initialized" sentinel value.
+///
+/// Types that lazily allocate must track initialization by some other means.
#[inline]
-unsafe fn null_pointer() -> NonNull<u8> {
- NonNull::new_unchecked(ALIGNMENT as *mut u8)
+fn dangling() -> NonNull<u8> {
+ // SAFETY: ALIGNMENT is a non-zero usize which is then casted
Review Comment:
This is copy-pasted from
https://doc.rust-lang.org/src/core/ptr/non_null.rs.html#90
##########
arrow-buffer/src/alloc/mod.rs:
##########
@@ -28,9 +28,18 @@ mod alignment;
pub use alignment::ALIGNMENT;
+/// Returns an aligned non null pointer similar to [`NonNull::dangling`]
+///
+/// Note that the pointer value may potentially represent a valid pointer,
which means
+/// this must not be used as a "not yet initialized" sentinel value.
+///
+/// Types that lazily allocate must track initialization by some other means.
#[inline]
-unsafe fn null_pointer() -> NonNull<u8> {
Review Comment:
This isn't actually unsafe see
https://doc.rust-lang.org/std/ptr/struct.NonNull.html#method.dangling
--
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]