blob: 0bc51534c915225a5010d0b5219702589962a751 [file] [log] [blame]
Lei Zhangd50bdff2019-02-05 19:42:33 +00001// 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
11TestLoader::TestLoader(const char* pBuf, size_t len)
12 : m_pBuf(pBuf), m_Len(len) {}
13
14// static
15int 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}