diff options
author | Tom Sepez <tsepez@chromium.org> | 2018-08-31 22:46:37 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-08-31 22:46:37 +0000 |
commit | a38996be8593ba78d3eb31e30d2d6f7c61990ec6 (patch) | |
tree | be978e80632c64f2d7bb46b879092d9d7f28a003 /core | |
parent | ca3a100e7dcf3671bd0774ec3f5233df6996dcea (diff) | |
download | pdfium-a38996be8593ba78d3eb31e30d2d6f7c61990ec6.tar.xz |
Remove avail_buf out argument from GetAvailInput() methods.chromium/3542chromium/3541chromium/3540chromium/3539
It's always passed as nullptr. It's a good thing, too, since it looks
like some of the implementations are returning a wrong pointer.
Add some missing |const|s.
Change-Id: I768048fdfe4cdd1dc838fee26fec18e024e39920
Reviewed-on: https://pdfium-review.googlesource.com/41810
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'core')
-rw-r--r-- | core/fxcodec/bmp/cfx_bmpdecompressor.cpp | 12 | ||||
-rw-r--r-- | core/fxcodec/bmp/cfx_bmpdecompressor.h | 2 | ||||
-rw-r--r-- | core/fxcodec/codec/ccodec_bmpmodule.cpp | 6 | ||||
-rw-r--r-- | core/fxcodec/codec/ccodec_bmpmodule.h | 2 | ||||
-rw-r--r-- | core/fxcodec/codec/ccodec_gifmodule.cpp | 6 | ||||
-rw-r--r-- | core/fxcodec/codec/ccodec_gifmodule.h | 2 | ||||
-rw-r--r-- | core/fxcodec/codec/ccodec_jpegmodule.cpp | 9 | ||||
-rw-r--r-- | core/fxcodec/codec/ccodec_jpegmodule.h | 2 | ||||
-rw-r--r-- | core/fxcodec/codec/ccodec_progressivedecoder.cpp | 13 | ||||
-rw-r--r-- | core/fxcodec/gif/cfx_gifcontext.cpp | 12 | ||||
-rw-r--r-- | core/fxcodec/gif/cfx_gifcontext.h | 2 |
11 files changed, 20 insertions, 48 deletions
diff --git a/core/fxcodec/bmp/cfx_bmpdecompressor.cpp b/core/fxcodec/bmp/cfx_bmpdecompressor.cpp index a25afdf6c9..de97c6d527 100644 --- a/core/fxcodec/bmp/cfx_bmpdecompressor.cpp +++ b/core/fxcodec/bmp/cfx_bmpdecompressor.cpp @@ -663,19 +663,11 @@ void CFX_BmpDecompressor::SetInputBuffer(pdfium::span<uint8_t> src_buf) { input_buffer_ = pdfium::MakeRetain<CFX_CodecMemory>(src_buf); } -FX_FILESIZE CFX_BmpDecompressor::GetAvailInput(uint8_t** avail_buf) { +FX_FILESIZE CFX_BmpDecompressor::GetAvailInput() const { if (!input_buffer_) return 0; - FX_FILESIZE available = - input_buffer_->GetSize() - input_buffer_->GetPosition(); - if (avail_buf) { - *avail_buf = nullptr; - if (available > 0) - *avail_buf = input_buffer_->GetBuffer() + available; - } - - return available; + return input_buffer_->GetSize() - input_buffer_->GetPosition(); } void CFX_BmpDecompressor::SetHeight(int32_t signed_height) { diff --git a/core/fxcodec/bmp/cfx_bmpdecompressor.h b/core/fxcodec/bmp/cfx_bmpdecompressor.h index ed013a2a09..331a6347b4 100644 --- a/core/fxcodec/bmp/cfx_bmpdecompressor.h +++ b/core/fxcodec/bmp/cfx_bmpdecompressor.h @@ -28,7 +28,7 @@ class CFX_BmpDecompressor { int32_t DecodeImage(); int32_t ReadHeader(); void SetInputBuffer(pdfium::span<uint8_t> src_buf); - FX_FILESIZE GetAvailInput(uint8_t** avail_buf); + FX_FILESIZE GetAvailInput() const; jmp_buf jmpbuf_; CFX_BmpContext* context_ptr_; diff --git a/core/fxcodec/codec/ccodec_bmpmodule.cpp b/core/fxcodec/codec/ccodec_bmpmodule.cpp index 75e59edf2b..ff4164ce4f 100644 --- a/core/fxcodec/codec/ccodec_bmpmodule.cpp +++ b/core/fxcodec/codec/ccodec_bmpmodule.cpp @@ -63,10 +63,8 @@ int32_t CCodec_BmpModule::LoadImage(Context* pContext) { return ctx->m_Bmp.DecodeImage(); } -FX_FILESIZE CCodec_BmpModule::GetAvailInput(Context* pContext, - uint8_t** avail_buf_ptr) { - auto* ctx = static_cast<CFX_BmpContext*>(pContext); - return ctx->m_Bmp.GetAvailInput(avail_buf_ptr); +FX_FILESIZE CCodec_BmpModule::GetAvailInput(Context* pContext) const { + return static_cast<CFX_BmpContext*>(pContext)->m_Bmp.GetAvailInput(); } void CCodec_BmpModule::Input(Context* pContext, pdfium::span<uint8_t> src_buf) { diff --git a/core/fxcodec/codec/ccodec_bmpmodule.h b/core/fxcodec/codec/ccodec_bmpmodule.h index 42d686e6f3..6dc0ebd860 100644 --- a/core/fxcodec/codec/ccodec_bmpmodule.h +++ b/core/fxcodec/codec/ccodec_bmpmodule.h @@ -34,7 +34,7 @@ class CCodec_BmpModule { ~CCodec_BmpModule(); std::unique_ptr<Context> Start(Delegate* pDelegate); - FX_FILESIZE GetAvailInput(Context* pContext, uint8_t** avail_buf_ptr); + FX_FILESIZE GetAvailInput(Context* pContext) const; void Input(Context* pContext, pdfium::span<uint8_t> src_buf); int32_t ReadHeader(Context* pContext, int32_t* width, diff --git a/core/fxcodec/codec/ccodec_gifmodule.cpp b/core/fxcodec/codec/ccodec_gifmodule.cpp index 872d90f770..a93cb27674 100644 --- a/core/fxcodec/codec/ccodec_gifmodule.cpp +++ b/core/fxcodec/codec/ccodec_gifmodule.cpp @@ -66,10 +66,8 @@ CFX_GifDecodeStatus CCodec_GifModule::LoadFrame(Context* pContext, return CFX_GifDecodeStatus::Success; } -uint32_t CCodec_GifModule::GetAvailInput(Context* pContext, - uint8_t** avail_buf_ptr) { - auto* context = static_cast<CFX_GifContext*>(pContext); - return context->GetAvailInput(avail_buf_ptr); +uint32_t CCodec_GifModule::GetAvailInput(Context* pContext) const { + return static_cast<CFX_GifContext*>(pContext)->GetAvailInput(); } void CCodec_GifModule::Input(Context* pContext, pdfium::span<uint8_t> src_buf) { diff --git a/core/fxcodec/codec/ccodec_gifmodule.h b/core/fxcodec/codec/ccodec_gifmodule.h index f14665ba2c..9529583426 100644 --- a/core/fxcodec/codec/ccodec_gifmodule.h +++ b/core/fxcodec/codec/ccodec_gifmodule.h @@ -43,7 +43,7 @@ class CCodec_GifModule { ~CCodec_GifModule(); std::unique_ptr<Context> Start(Delegate* pDelegate); - uint32_t GetAvailInput(Context* context, uint8_t** avail_buf_ptr); + uint32_t GetAvailInput(Context* context) const; void Input(Context* context, pdfium::span<uint8_t> src_buf); CFX_GifDecodeStatus ReadHeader(Context* context, int* width, diff --git a/core/fxcodec/codec/ccodec_jpegmodule.cpp b/core/fxcodec/codec/ccodec_jpegmodule.cpp index e6aef3c05b..aaf16ae762 100644 --- a/core/fxcodec/codec/ccodec_jpegmodule.cpp +++ b/core/fxcodec/codec/ccodec_jpegmodule.cpp @@ -464,15 +464,8 @@ bool CCodec_JpegModule::ReadScanline(Context* pContext, return nlines == 1; } -uint32_t CCodec_JpegModule::GetAvailInput(Context* pContext, - uint8_t** avail_buf_ptr) { +uint32_t CCodec_JpegModule::GetAvailInput(Context* pContext) const { auto* ctx = static_cast<CJpegContext*>(pContext); - if (avail_buf_ptr) { - *avail_buf_ptr = nullptr; - if (ctx->m_SrcMgr.bytes_in_buffer > 0) { - *avail_buf_ptr = (uint8_t*)ctx->m_SrcMgr.next_input_byte; - } - } return (uint32_t)ctx->m_SrcMgr.bytes_in_buffer; } diff --git a/core/fxcodec/codec/ccodec_jpegmodule.h b/core/fxcodec/codec/ccodec_jpegmodule.h index fb116f5d88..2c72db3316 100644 --- a/core/fxcodec/codec/ccodec_jpegmodule.h +++ b/core/fxcodec/codec/ccodec_jpegmodule.h @@ -56,7 +56,7 @@ class CCodec_JpegModule { bool StartScanline(Context* pContext, int down_scale); bool ReadScanline(Context* pContext, uint8_t* dest_buf); - uint32_t GetAvailInput(Context* pContext, uint8_t** avail_buf_ptr); + uint32_t GetAvailInput(Context* pContext) const; #if _FX_PLATFORM_ == _FX_PLATFORM_WINDOWS_ static bool JpegEncode(const RetainPtr<CFX_DIBBase>& pSource, diff --git a/core/fxcodec/codec/ccodec_progressivedecoder.cpp b/core/fxcodec/codec/ccodec_progressivedecoder.cpp index 6faaaa11cd..280b647ebd 100644 --- a/core/fxcodec/codec/ccodec_progressivedecoder.cpp +++ b/core/fxcodec/codec/ccodec_progressivedecoder.cpp @@ -418,7 +418,7 @@ void CCodec_ProgressiveDecoder::PngFillScanlineBufCompleted(int pass, #ifdef PDF_ENABLE_XFA_GIF void CCodec_ProgressiveDecoder::GifRecordCurrentPosition(uint32_t& cur_pos) { uint32_t remain_size = - m_pCodecMgr->GetGifModule()->GetAvailInput(m_pGifContext.get(), nullptr); + m_pCodecMgr->GetGifModule()->GetAvailInput(m_pGifContext.get()); cur_pos = m_offSet - remain_size; } @@ -805,7 +805,7 @@ bool CCodec_ProgressiveDecoder::BmpReadMoreData( return false; dwSize = dwSize - m_offSet; - FX_SAFE_UINT32 avail_input = pBmpModule->GetAvailInput(pBmpContext, nullptr); + FX_SAFE_UINT32 avail_input = pBmpModule->GetAvailInput(pBmpContext); if (!avail_input.IsValid()) return false; @@ -898,10 +898,9 @@ bool CCodec_ProgressiveDecoder::GifReadMoreData(CCodec_GifModule* pGifModule, return false; uint32_t dwFileRemaining = m_pFile->GetSize() - m_offSet; - uint32_t dwUnusedBuffer = - !m_InvalidateGifBuffer - ? pGifModule->GetAvailInput(m_pGifContext.get(), nullptr) - : 0; + uint32_t dwUnusedBuffer = !m_InvalidateGifBuffer + ? pGifModule->GetAvailInput(m_pGifContext.get()) + : 0; uint32_t dwAmountToFetchFromFile = dwFileRemaining; if (dwUnusedBuffer == m_SrcSize) { if (dwFileRemaining > FXCODEC_BLOCK_SIZE) @@ -1129,7 +1128,7 @@ bool CCodec_ProgressiveDecoder::JpegReadMoreData(CCodec_JpegModule* pJpegModule, return false; } dwSize = dwSize - m_offSet; - uint32_t dwAvail = pJpegModule->GetAvailInput(m_pJpegContext.get(), nullptr); + uint32_t dwAvail = pJpegModule->GetAvailInput(m_pJpegContext.get()); if (dwAvail == m_SrcSize) { if (dwSize > FXCODEC_BLOCK_SIZE) { dwSize = FXCODEC_BLOCK_SIZE; diff --git a/core/fxcodec/gif/cfx_gifcontext.cpp b/core/fxcodec/gif/cfx_gifcontext.cpp index f746bc13c5..8f48cfde48 100644 --- a/core/fxcodec/gif/cfx_gifcontext.cpp +++ b/core/fxcodec/gif/cfx_gifcontext.cpp @@ -346,19 +346,11 @@ void CFX_GifContext::SetInputBuffer(pdfium::span<uint8_t> src_buf) { input_buffer_ = pdfium::MakeRetain<CFX_CodecMemory>(src_buf); } -uint32_t CFX_GifContext::GetAvailInput(uint8_t** avail_buf) const { +uint32_t CFX_GifContext::GetAvailInput() const { if (!input_buffer_) return 0; - FX_FILESIZE available_size = - input_buffer_->GetSize() - input_buffer_->GetPosition(); - if (avail_buf) { - *avail_buf = nullptr; - if (available_size > 0) - *avail_buf = input_buffer_->GetBuffer() + available_size; - } - - return available_size; + return input_buffer_->GetSize() - input_buffer_->GetPosition(); } bool CFX_GifContext::ReadData(uint8_t* dest, uint32_t size) { diff --git a/core/fxcodec/gif/cfx_gifcontext.h b/core/fxcodec/gif/cfx_gifcontext.h index 90657b05bb..9cc7da9615 100644 --- a/core/fxcodec/gif/cfx_gifcontext.h +++ b/core/fxcodec/gif/cfx_gifcontext.h @@ -42,7 +42,7 @@ class CFX_GifContext : public CCodec_GifModule::Context { CFX_GifDecodeStatus GetFrame(); CFX_GifDecodeStatus LoadFrame(int32_t frame_num); void SetInputBuffer(pdfium::span<uint8_t> src_buf); - uint32_t GetAvailInput(uint8_t** avail_buf) const; + uint32_t GetAvailInput() const; size_t GetFrameNum() const { return images_.size(); } UnownedPtr<CCodec_GifModule> gif_module_; |