Skip to content

Commit

Permalink
ARROW-4488: [Rust] From AsRef<[u8]> for Buffer does not ensure correc…
Browse files Browse the repository at this point in the history
…t 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 #3568 from paddyhoran/asref-padding and squashes the following commits:

05cb0e9 <Paddy Horan> Ensures padding to a multiple of 64 bytes
  • Loading branch information
paddyhoran authored and xhochy committed Feb 8, 2019
1 parent 842fdd8 commit 5863a9f
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion rust/arrow/src/buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 5863a9f

Please sign in to comment.