Remove use of SkTAddOffset and sk_careful_memcpy (flutter/engine#38977)

This commit is contained in:
Kevin Lubick
2023-01-18 12:58:59 -05:00
committed by GitHub
parent c7e72afb3d
commit 0c0e36e37f

View File

@@ -23,8 +23,14 @@ static void CopyV(void* dst, const S* src, int n, Rest&&... rest) {
FML_DCHECK(((uintptr_t)dst & (alignof(S) - 1)) == 0)
<< "Expected " << dst << " to be aligned for at least " << alignof(S)
<< " bytes.";
sk_careful_memcpy(dst, src, n * sizeof(S));
CopyV(SkTAddOffset<void>(dst, n * sizeof(S)), std::forward<Rest>(rest)...);
// If n is 0, there is nothing to copy into dst from src.
if (n > 0) {
memcpy(dst, src, n * sizeof(S));
dst = reinterpret_cast<void*>(reinterpret_cast<uint8_t*>(dst) +
n * sizeof(S));
}
// Repeat for the next items, if any
CopyV(dst, std::forward<Rest>(rest)...);
}
static constexpr inline bool is_power_of_two(int value) {