41 if (buffer.empty() || offset < 0)
44 FX_SAFE_SIZE_T new_pos = buffer.size();
46 if (!new_pos.IsValid() || new_pos.ValueOrDefault(0) == 0 ||
47 new_pos.ValueOrDie() > m_nCurSize) {
51 m_nCurPos = new_pos.ValueOrDie();
54 fxcrt::spancpy(buffer,
55 GetSpan().subspan(
static_cast<size_t>(offset), buffer.size()));
60 if (m_nCurPos >= m_nCurSize)
63 size_t nRead = std::min(buffer.size(), m_nCurSize - m_nCurPos);
64 if (!ReadBlockAtOffset(buffer.first(nRead),
static_cast<int32_t>(m_nCurPos)))
78 FX_SAFE_SIZE_T safe_new_pos = buffer.size();
79 safe_new_pos += offset;
80 if (!safe_new_pos.IsValid())
83 size_t new_pos = safe_new_pos.ValueOrDie();
84 if (new_pos > m_data.size()) {
85 static constexpr size_t kBlockSize = 64 * 1024;
86 FX_SAFE_SIZE_T new_size = new_pos;
88 new_size += (kBlockSize - 1);
89 new_size /= kBlockSize;
90 new_size *= kBlockSize;
91 if (!new_size.IsValid())
94 m_data.resize(new_size.ValueOrDie());
100 fxcrt::spancpy(pdfium::make_span(m_data).subspan(
static_cast<size_t>(offset)),
102 m_nCurSize = std::max(m_nCurSize, m_nCurPos);