| // Copyright 2019 PDFium Authors. All rights reserved. |
| // 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 <string.h> |
| |
| #include "third_party/base/logging.h" |
| |
| TestLoader::TestLoader(const char* pBuf, size_t len) |
| : m_pBuf(pBuf), m_Len(len) {} |
| |
| // static |
| int TestLoader::GetBlock(void* param, |
| unsigned long pos, |
| unsigned char* pBuf, |
| unsigned long size) { |
| TestLoader* pLoader = static_cast<TestLoader*>(param); |
| if (pos + size < pos || pos + size > pLoader->m_Len) { |
| NOTREACHED(); |
| return 0; |
| } |
| |
| memcpy(pBuf, pLoader->m_pBuf + pos, size); |
| return 1; |
| } |