Lei Zhang | d50bdff | 2019-02-05 19:42:33 +0000 | [diff] [blame^] | 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 | |
| 11 | TestLoader::TestLoader(const char* pBuf, size_t len) |
| 12 | : m_pBuf(pBuf), m_Len(len) {} |
| 13 | |
| 14 | // static |
| 15 | int TestLoader::GetBlock(void* param, |
| 16 | unsigned long pos, |
| 17 | unsigned char* pBuf, |
| 18 | unsigned long size) { |
| 19 | TestLoader* pLoader = static_cast<TestLoader*>(param); |
| 20 | if (pos + size < pos || pos + size > pLoader->m_Len) { |
| 21 | NOTREACHED(); |
| 22 | return 0; |
| 23 | } |
| 24 | |
| 25 | memcpy(pBuf, pLoader->m_pBuf + pos, size); |
| 26 | return 1; |
| 27 | } |