You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2020/04/29 22:51:33 UTC

[GitHub] [arrow] andygrove commented on a change in pull request #7061: ARROW-8629: [Rust] Eliminate indirection of zero sized allocations

andygrove commented on a change in pull request #7061:
URL: https://github.com/apache/arrow/pull/7061#discussion_r417658203



##########
File path: rust/arrow/src/memory.rs
##########
@@ -20,34 +20,56 @@
 
 use std::alloc::Layout;
 use std::mem::align_of;
+use std::ptr::NonNull;
 
 pub const ALIGNMENT: usize = 64;
 
+///
+/// As you can see this is global and lives as long as the program lives.
+/// Be careful to not write anything to this pointer in any scenario.
+/// If you use allocation methods shown here you won't have any problems.
+const BYPASS_PTR: NonNull<u8> = unsafe { NonNull::new_unchecked(0xDEADBEEF as *mut u8) };
+
 pub fn allocate_aligned(size: usize) -> *mut u8 {
     unsafe {

Review comment:
       I'm not familiar with the use case of calling this with zero. Should that even be allowed?




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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org