From 0b10048858ea0b9ab6559a01d5e6ffc2991b03ee Mon Sep 17 00:00:00 2001 From: Huang-Ming Huang Date: Fri, 10 Jan 2025 17:17:13 -0600 Subject: [PATCH] use std::memcpy --- include/hpp_proto/json_serializer.hpp | 2 +- include/hpp_proto/pb_serializer.hpp | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/hpp_proto/json_serializer.hpp b/include/hpp_proto/json_serializer.hpp index 9795948..656fa68 100644 --- a/include/hpp_proto/json_serializer.hpp +++ b/include/hpp_proto/json_serializer.hpp @@ -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(base64_chars[(x >> 2U) & 0x3FU]); diff --git a/include/hpp_proto/pb_serializer.hpp b/include/hpp_proto/pb_serializer.hpp index 2d86da2..d748d2d 100644 --- a/include/hpp_proto/pb_serializer.hpp +++ b/include/hpp_proto/pb_serializer.hpp @@ -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>()); } @@ -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); @@ -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); }