replace memcpy with std::copy

This commit is contained in:
Konstantinos Margaritis 2024-05-11 18:47:00 +03:00
parent 0f61853a37
commit a2e66e31d2

View File

@ -115,28 +115,36 @@ void write_out(scatter_full_plan *plan_out, void *aux_out,
plan_out->s_u64a_offset = aux_base_offset;
plan_out->s_u64a_count = raw.p_u64a.size();
assert(ISALIGNED_N(static_cast<char *>(aux_out) + aux_base_offset, alignof(scatter_unit_u64a)));
memcpy(static_cast<char *>(aux_out) + aux_base_offset, raw.p_u64a.data(), byte_length(raw.p_u32));
auto *start = reinterpret_cast<const char *>(raw.p_u64a.data());
auto *to = static_cast<char *>(aux_out) + aux_base_offset;
std::copy(start, start + byte_length(raw.p_u64a), to);
aux_base_offset += byte_length(raw.p_u64a);
}
if (!raw.p_u32.empty()) {
plan_out->s_u32_offset = aux_base_offset;
plan_out->s_u32_count = raw.p_u32.size();
assert(ISALIGNED_N(static_cast<char *>(aux_out) + aux_base_offset, alignof(scatter_unit_u32)));
memcpy(static_cast<char *>(aux_out) + aux_base_offset, raw.p_u32.data(), byte_length(raw.p_u32));
auto *start = reinterpret_cast<const char *>(raw.p_u32.data());
auto *to = static_cast<char *>(aux_out) + aux_base_offset;
std::copy(start, start + byte_length(raw.p_u32), to);
aux_base_offset += byte_length(raw.p_u32);
}
if (!raw.p_u16.empty()) {
plan_out->s_u16_offset = aux_base_offset;
plan_out->s_u16_count = raw.p_u16.size();
assert(ISALIGNED_N(static_cast<char *>(aux_out) + aux_base_offset, alignof(scatter_unit_u16)));
memcpy(static_cast<char *>(aux_out) + aux_base_offset, raw.p_u16.data(), byte_length(raw.p_u16));
auto *start = reinterpret_cast<const char *>(raw.p_u16.data());
auto *to = static_cast<char *>(aux_out) + aux_base_offset;
std::copy(start, start + byte_length(raw.p_u16), to);
aux_base_offset += byte_length(raw.p_u16);
}
if (!raw.p_u8.empty()) {
plan_out->s_u8_offset = aux_base_offset;
plan_out->s_u8_count = raw.p_u8.size();
assert(ISALIGNED_N(static_cast<char *>(aux_out) + aux_base_offset, alignof(scatter_unit_u8)));
memcpy(static_cast<char *>(aux_out) + aux_base_offset, raw.p_u8.data(), byte_length(raw.p_u8));
auto *start = reinterpret_cast<const char *>(raw.p_u8.data());
auto *to = static_cast<char *>(aux_out) + aux_base_offset;
std::copy(start, start + byte_length(raw.p_u8), to);
}
}