This is an automated email from the ASF dual-hosted git repository.

kszucs pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow.git


The following commit(s) were added to refs/heads/master by this push:
     new 4c680ca  ARROW-4488: [Rust] From AsRef<[u8]> for Buffer does not 
ensure correct padding
4c680ca is described below

commit 4c680ca23c7062823e6d0ae6fb2a4dd0485bf5f2
Author: Paddy Horan <[email protected]>
AuthorDate: Wed Feb 6 11:48:58 2019 +0100

    ARROW-4488: [Rust] From AsRef<[u8]> for Buffer does not ensure correct 
padding
    
    Padding for all memory allocations needs to be a multiple of 64 bytes to 
make SIMD implementations easier and more efficient to implement.
    
    Author: Paddy Horan <[email protected]>
    
    Closes #3568 from paddyhoran/asref-padding and squashes the following 
commits:
    
    05cb0e99 <Paddy Horan> Ensures padding to a multiple of 64 bytes
---
 rust/arrow/src/buffer.rs | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/rust/arrow/src/buffer.rs b/rust/arrow/src/buffer.rs
index 6172445..70aea63 100644
--- a/rust/arrow/src/buffer.rs
+++ b/rust/arrow/src/buffer.rs
@@ -132,7 +132,8 @@ impl<T: AsRef<[u8]>> From<T> for Buffer {
         // allocate aligned memory buffer
         let slice = p.as_ref();
         let len = slice.len() * mem::size_of::<u8>();
-        let buffer = memory::allocate_aligned(len).unwrap();
+        let capacity = bit_util::round_upto_multiple_of_64(len);
+        let buffer = memory::allocate_aligned(capacity).unwrap();
         unsafe {
             memory::memcpy(buffer, slice.as_ptr(), len);
         }

Reply via email to