diff options
author | Tom Sepez <tsepez@chromium.org> | 2018-08-24 19:45:09 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-08-24 19:45:09 +0000 |
commit | 16d18d935d055b74e05f615c0325318a329a7fe1 (patch) | |
tree | bce3c35b6db03cedd537a67a28cf91eb0b502b1c /core/fxcodec/codec/cfx_codec_memory.cpp | |
parent | 1cb4d6b14cc9375dc04f57d3f2149eccb9e327a8 (diff) | |
download | pdfium-16d18d935d055b74e05f615c0325318a329a7fe1.tar.xz |
Use span<uint8_t> in more fxcodec code.
There are also small tweaks in tests to ensure strict order of
stack variable lifetimes.
Change-Id: Ic9d5c6a2bdd378b517be627f8e29f725bafdc2ad
Reviewed-on: https://pdfium-review.googlesource.com/41310
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'core/fxcodec/codec/cfx_codec_memory.cpp')
-rw-r--r-- | core/fxcodec/codec/cfx_codec_memory.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/core/fxcodec/codec/cfx_codec_memory.cpp b/core/fxcodec/codec/cfx_codec_memory.cpp index 8eac02c9ee..b8cf97b098 100644 --- a/core/fxcodec/codec/cfx_codec_memory.cpp +++ b/core/fxcodec/codec/cfx_codec_memory.cpp @@ -6,13 +6,13 @@ #include <algorithm> -CFX_CodecMemory::CFX_CodecMemory(uint8_t* buffer, size_t size) - : buffer_(buffer), size_(size) {} +CFX_CodecMemory::CFX_CodecMemory(pdfium::span<uint8_t> buffer) + : buffer_(buffer) {} CFX_CodecMemory::~CFX_CodecMemory() = default; bool CFX_CodecMemory::Seek(size_t pos) { - if (pos > size_) + if (pos > buffer_.size()) return false; pos_ = pos; @@ -23,7 +23,7 @@ size_t CFX_CodecMemory::ReadBlock(void* buffer, size_t size) { if (!buffer || !size || IsEOF()) return 0; - size_t bytes_to_read = std::min(size, size_ - pos_); + size_t bytes_to_read = std::min(size, buffer_.size() - pos_); memcpy(buffer, &buffer_[pos_], bytes_to_read); pos_ += bytes_to_read; return bytes_to_read; |