westonpace commented on code in PR #35565:
URL: https://github.com/apache/arrow/pull/35565#discussion_r1205260531
##########
cpp/src/arrow/util/align_util.cc:
##########
@@ -94,12 +135,17 @@ bool CheckAlignment(const Table& table, int64_t alignment,
return all_aligned;
}
+// Most allocators require a minimum of 8-byte alignment.
+constexpr int64_t kMinimumAlignment = 8;
Review Comment:
At the end of the day we end up with:
```
const int result =
posix_memalign(reinterpret_cast<void**>(out),
static_cast<size_t>(alignment),
static_cast<size_t>(size));
if (result == ENOMEM) {
return Status::OutOfMemory("malloc of size ", size, " failed");
}
if (result == EINVAL) {
return Status::Invalid("invalid alignment parameter: ",
static_cast<size_t>(alignment));
}
```
The docs for `posix_memalign` state:
```
The address of the
allocated memory will be a multiple of alignment, which must be a
power of two and a multiple of sizeof(void *)
```
`sizeof(void*)` is 8 and so when I pass 4 I get:
```
'_error_or_value28.status()' failed with Invalid: invalid alignment
parameter: 4
```
--
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]