From a765a644e8d6d747e571ba608f0080a21075ebbd Mon Sep 17 00:00:00 2001 From: Kevin Lubick Date: Wed, 18 Jan 2023 11:03:04 -0500 Subject: [PATCH] Remove use of SkTAddOffset and sk_careful_memcpy --- display_list/display_list_builder.cc | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/display_list/display_list_builder.cc b/display_list/display_list_builder.cc index cdc400b192b07..970601b53c13a 100644 --- a/display_list/display_list_builder.cc +++ b/display_list/display_list_builder.cc @@ -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(dst, n * sizeof(S)), std::forward(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(reinterpret_cast(dst) + + n * sizeof(S)); + } + // Repeat for the next items, if any + CopyV(dst, std::forward(rest)...); } static constexpr inline bool is_power_of_two(int value) {