pdfium/testing/test_loader.cpp
Tom Sepez d94fd720a0 Remove spurious includes of <string.h>.
<string.h> should be banished as its functions are unsafe.

-- Fix IWYU in header files moving some inclusions from .cpp file.
-- Convert include to stdddef.h/stdint.h if size_t or uint*_t types
   used directly in file.

Change-Id: If39d62d67f8f2cf3d78b5d3603fd14d9d697db35
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/118913
Reviewed-by: Thomas Sepez <tsepez@google.com>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
2024-05-09 21:07:00 +00:00

28 lines
817 B
C++

// Copyright 2019 The PDFium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "testing/test_loader.h"
#include <stddef.h>
#include "core/fxcrt/check_op.h"
#include "core/fxcrt/fx_memcpy_wrappers.h"
#include "core/fxcrt/numerics/checked_math.h"
TestLoader::TestLoader(pdfium::span<const uint8_t> span) : m_Span(span) {}
// static
int TestLoader::GetBlock(void* param,
unsigned long pos,
unsigned char* pBuf,
unsigned long size) {
TestLoader* pLoader = static_cast<TestLoader*>(param);
pdfium::CheckedNumeric<size_t> end = pos;
end += size;
CHECK_LE(end.ValueOrDie(), pLoader->m_Span.size());
FXSYS_memcpy(pBuf, &pLoader->m_Span[pos], size);
return 1;
}