// Copyright 2021 The PDFium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef CORE_FXCRT_SPAN_UTIL_H_ #define CORE_FXCRT_SPAN_UTIL_H_ #include #include "third_party/base/check_op.h" #include "third_party/base/span.h" namespace fxcrt { // Bounds-checked copies from spans into spans. template > void spancpy(pdfium::span dst, pdfium::span src) { CHECK_GE(dst.size_bytes(), src.size_bytes()); memcpy(dst.data(), src.data(), src.size_bytes()); } // Bounds-checked moves from spans into spans. template > void spanmove(pdfium::span dst, pdfium::span src) { CHECK_GE(dst.size_bytes(), src.size_bytes()); memmove(dst.data(), src.data(), src.size_bytes()); } // Bounds-checked sets into spans. template void spanset(pdfium::span dst, uint8_t val) { memset(dst.data(), val, dst.size_bytes()); } // Bounds-checked zeroing of spans. template void spanclr(pdfium::span dst) { memset(dst.data(), 0, dst.size_bytes()); } } // namespace fxcrt #endif // CORE_FXCRT_SPAN_UTIL_H_