• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2019 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #include "testing/test_loader.h"
6 
7 #include <string.h>
8 
9 #include "third_party/base/logging.h"
10 
TestLoader(pdfium::span<const char> span)11 TestLoader::TestLoader(pdfium::span<const char> span) : m_Span(span) {}
12 
13 // static
GetBlock(void * param,unsigned long pos,unsigned char * pBuf,unsigned long size)14 int TestLoader::GetBlock(void* param,
15                          unsigned long pos,
16                          unsigned char* pBuf,
17                          unsigned long size) {
18   TestLoader* pLoader = static_cast<TestLoader*>(param);
19   if (pos + size < pos || pos + size > pLoader->m_Span.size()) {
20     NOTREACHED();
21     return 0;
22   }
23 
24   memcpy(pBuf, &pLoader->m_Span[pos], size);
25   return 1;
26 }
27