Skip to content

Commit 5863a9f

Browse files
paddyhoranxhochy
authored andcommitted
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 <paddyhoran@hotmail.com> Closes apache#3568 from paddyhoran/asref-padding and squashes the following commits: 05cb0e9 <Paddy Horan> Ensures padding to a multiple of 64 bytes
1 parent 842fdd8 commit 5863a9f

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

rust/arrow/src/buffer.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,8 @@ impl<T: AsRef<[u8]>> From<T> for Buffer {
132132
// allocate aligned memory buffer
133133
let slice = p.as_ref();
134134
let len = slice.len() * mem::size_of::<u8>();
135-
let buffer = memory::allocate_aligned(len).unwrap();
135+
let capacity = bit_util::round_upto_multiple_of_64(len);
136+
let buffer = memory::allocate_aligned(capacity).unwrap();
136137
unsafe {
137138
memory::memcpy(buffer, slice.as_ptr(), len);
138139
}

0 commit comments

Comments
 (0)