Skip to content

Commit

Permalink
use std::memcpy
Browse files Browse the repository at this point in the history
  • Loading branch information
huangminghuang committed Jan 10, 2025
1 parent 7efde1b commit 0b10048
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion include/hpp_proto/json_serializer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ struct base64 {
for (i = 0; i <= n - 3; i += 3) {
uint32_t x = 0;

memcpy(&x, &source[i], 3);
std::memcpy(&x, &source[i], 3);

if constexpr (std::endian::native == std::endian::little) {
b[ix++] = static_cast<V>(base64_chars[(x >> 2U) & 0x3FU]);
Expand Down
6 changes: 3 additions & 3 deletions include/hpp_proto/pb_serializer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1097,7 +1097,7 @@ class sfvint_parser {
end -= ((end - begin) % mask_length);
for (; begin < end; begin += mask_length) {
uint64_t word = 0;
memcpy(&word, begin, sizeof(word));
std::memcpy(&word, begin, sizeof(word));
auto mval = pext_u64(word, word_mask);
parse_word(mval, word, std::make_index_sequence<1U << mask_length>());
}
Expand All @@ -1110,7 +1110,7 @@ class sfvint_parser {
auto end = std::ranges::cend(r);
ptrdiff_t bytes_left = end - begin;
uint64_t word = 0;
memcpy(&word, begin, bytes_left);
std::memcpy(&word, begin, bytes_left);
for (; bytes_left > 0; --bytes_left, word >>= CHAR_BIT) {
pt_val |= ((word & 0x7fULL) << shift_bits);
has_error |= (shift_bits >= max_effective_bits);
Expand Down Expand Up @@ -1987,7 +1987,7 @@ struct pb_serializer {
while (data.size()) {
uint64_t v = 0;
auto bytes = data.consume(sizeof(v));
memcpy(&v, bytes.data(), bytes.size());
std::memcpy(&v, bytes.data(), bytes.size());
result += popcount(~v & 0x8080808080808080ULL);
}

Expand Down

0 comments on commit 0b10048

Please sign in to comment.