diff options
-rw-r--r-- | core/fpdftext/cpdf_textpage.cpp | 2 | ||||
-rw-r--r-- | core/fxcodec/codec/fx_codec_fax.cpp | 2 | ||||
-rw-r--r-- | core/fxcrt/cfx_binarybuf.cpp | 6 | ||||
-rw-r--r-- | core/fxcrt/cfx_binarybuf.h | 9 |
4 files changed, 9 insertions, 10 deletions
diff --git a/core/fpdftext/cpdf_textpage.cpp b/core/fpdftext/cpdf_textpage.cpp index ed7f36fb6c..eccac12b22 100644 --- a/core/fpdftext/cpdf_textpage.cpp +++ b/core/fpdftext/cpdf_textpage.cpp @@ -217,7 +217,7 @@ PAGECHAR_INFO::~PAGECHAR_INFO() {} CPDF_TextPage::CPDF_TextPage(const CPDF_Page* pPage, FPDFText_Direction flags) : m_pPage(pPage), m_parserflag(flags) { - m_TextBuf.EstimateSize(0, 10240); + m_TextBuf.SetAllocStep(10240); const FX_RECT rect(0, 0, static_cast<int>(pPage->GetPageWidth()), static_cast<int>(pPage->GetPageHeight())); m_DisplayMatrix = pPage->GetDisplayMatrix(rect, 0); diff --git a/core/fxcodec/codec/fx_codec_fax.cpp b/core/fxcodec/codec/fx_codec_fax.cpp index 2c85e2dc8b..aabc110010 100644 --- a/core/fxcodec/codec/fx_codec_fax.cpp +++ b/core/fxcodec/codec/fx_codec_fax.cpp @@ -759,7 +759,7 @@ CCodec_FaxEncoder::CCodec_FaxEncoder(const uint8_t* src_buf, m_RefLine.resize(m_Pitch); memset(m_RefLine.data(), 0xff, m_Pitch); m_pLineBuf = FX_Alloc2D(uint8_t, m_Pitch, 8); - m_DestBuf.EstimateSize(0, 10240); + m_DestBuf.SetAllocStep(10240); } CCodec_FaxEncoder::~CCodec_FaxEncoder() { diff --git a/core/fxcrt/cfx_binarybuf.cpp b/core/fxcrt/cfx_binarybuf.cpp index 5ef907cb80..67aa29263b 100644 --- a/core/fxcrt/cfx_binarybuf.cpp +++ b/core/fxcrt/cfx_binarybuf.cpp @@ -9,8 +9,7 @@ #include <algorithm> #include <utility> -CFX_BinaryBuf::CFX_BinaryBuf() - : m_AllocStep(0), m_AllocSize(0), m_DataSize(0) {} +CFX_BinaryBuf::CFX_BinaryBuf() = default; CFX_BinaryBuf::~CFX_BinaryBuf() = default; @@ -37,8 +36,7 @@ std::unique_ptr<uint8_t, FxFreeDeleter> CFX_BinaryBuf::DetachBuffer() { return std::move(m_pBuffer); } -void CFX_BinaryBuf::EstimateSize(size_t size, size_t step) { - m_AllocStep = step; +void CFX_BinaryBuf::EstimateSize(size_t size) { if (m_AllocSize < size) ExpandBuf(size - m_DataSize); } diff --git a/core/fxcrt/cfx_binarybuf.h b/core/fxcrt/cfx_binarybuf.h index 2d4f019560..b519d57e10 100644 --- a/core/fxcrt/cfx_binarybuf.h +++ b/core/fxcrt/cfx_binarybuf.h @@ -24,7 +24,8 @@ class CFX_BinaryBuf { bool IsEmpty() const { return GetLength() == 0; } void Clear(); - void EstimateSize(size_t size, size_t alloc_step = 0); + void SetAllocStep(size_t step) { m_AllocStep = step; } + void EstimateSize(size_t size); void AppendBlock(const void* pBuf, size_t size); void AppendString(const ByteString& str) { AppendBlock(str.c_str(), str.GetLength()); @@ -43,9 +44,9 @@ class CFX_BinaryBuf { protected: void ExpandBuf(size_t size); - size_t m_AllocStep; - size_t m_AllocSize; - size_t m_DataSize; + size_t m_AllocStep = 0; + size_t m_AllocSize = 0; + size_t m_DataSize = 0; std::unique_ptr<uint8_t, FxFreeDeleter> m_pBuffer; }; |