Skip to content

Commit

Permalink
Use safe unaligned loads and stores
Browse files Browse the repository at this point in the history
  • Loading branch information
pitrou committed Nov 1, 2023
1 parent 063e5ed commit 659b27a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions cpp/src/arrow/util/byte_stream_split_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,7 @@ inline void DoSplitStreams(const uint8_t* src, int width, int64_t nvalues,
uint64_t r = (a << 56) | (b << 48) | (c << 40) | (d << 32) | (e << 24) |
(f << 16) | (g << 8) | h;
#endif
*reinterpret_cast<uint64_t*>(&dest[i]) = r;
arrow::util::SafeStore(&dest[i], r);
}
dest_streams[stream] += kBlockSize;
}
Expand Down Expand Up @@ -648,7 +648,7 @@ inline void DoMergeStreams(const uint8_t** src_streams, int width, int64_t nvalu
// to their logical places in destination.
const uint8_t* src = src_streams[stream];
for (int i = 0; i < kBlockSize; i += 8) {
uint64_t v = *reinterpret_cast<const uint64_t*>(&src[i]);
uint64_t v = arrow::util::SafeLoadAs<uint64_t>(&src[i]);
#if ARROW_LITTLE_ENDIAN
dest[stream + i * width] = static_cast<uint8_t>(v);
dest[stream + (i + 1) * width] = static_cast<uint8_t>(v >> 8);
Expand Down

0 comments on commit 659b27a

Please sign in to comment.