diff options
author | Lei Zhang <thestig@chromium.org> | 2016-01-08 15:31:47 -0800 |
---|---|---|
committer | Lei Zhang <thestig@chromium.org> | 2016-01-08 15:31:47 -0800 |
commit | 9adfbb0920a258e916003b1ee9515e97879db82a (patch) | |
tree | 69c568cf9857ea028da91cc3a73f15a21a2c4c73 /core/src/fxcrt/extension.h | |
parent | e5ae7226fc3ffad3f76995d31a0f6b2254d50656 (diff) | |
download | pdfium-9adfbb0920a258e916003b1ee9515e97879db82a.tar.xz |
Switch most min/max macros to std::min/max.
Fix lint errors along the way.
R=tsepez@chromium.org
Review URL: https://codereview.chromium.org/1567343002 .
Diffstat (limited to 'core/src/fxcrt/extension.h')
-rw-r--r-- | core/src/fxcrt/extension.h | 61 |
1 files changed, 23 insertions, 38 deletions
diff --git a/core/src/fxcrt/extension.h b/core/src/fxcrt/extension.h index 58b0457a7c..fbf040d40d 100644 --- a/core/src/fxcrt/extension.h +++ b/core/src/fxcrt/extension.h @@ -7,6 +7,8 @@ #ifndef CORE_SRC_FXCRT_EXTENSION_H_ #define CORE_SRC_FXCRT_EXTENSION_H_ +#include <algorithm> + #include "core/include/fxcrt/fx_basic.h" #include "core/include/fxcrt/fx_safe_types.h" @@ -33,39 +35,21 @@ IFXCRT_FileAccess* FXCRT_FileAccess_Create(); class CFX_CRTFileStream final : public IFX_FileStream { public: - CFX_CRTFileStream(IFXCRT_FileAccess* pFA) : m_pFile(pFA), m_dwCount(1) {} - ~CFX_CRTFileStream() override { - if (m_pFile) { - m_pFile->Release(); - } - } - virtual IFX_FileStream* Retain() override { - m_dwCount++; - return this; - } - virtual void Release() override { - FX_DWORD nCount = --m_dwCount; - if (!nCount) { - delete this; - } - } - virtual FX_FILESIZE GetSize() override { return m_pFile->GetSize(); } - virtual FX_BOOL IsEOF() override { return GetPosition() >= GetSize(); } - virtual FX_FILESIZE GetPosition() override { return m_pFile->GetPosition(); } - virtual FX_BOOL ReadBlock(void* buffer, - FX_FILESIZE offset, - size_t size) override { - return (FX_BOOL)m_pFile->ReadPos(buffer, size, offset); - } - virtual size_t ReadBlock(void* buffer, size_t size) override { - return m_pFile->Read(buffer, size); - } - virtual FX_BOOL WriteBlock(const void* buffer, - FX_FILESIZE offset, - size_t size) override { - return (FX_BOOL)m_pFile->WritePos(buffer, size, offset); - } - virtual FX_BOOL Flush() override { return m_pFile->Flush(); } + explicit CFX_CRTFileStream(IFXCRT_FileAccess* pFA); + ~CFX_CRTFileStream() override; + + // IFX_FileStream: + IFX_FileStream* Retain() override; + void Release() override; + FX_FILESIZE GetSize() override; + FX_BOOL IsEOF() override; + FX_FILESIZE GetPosition() override; + FX_BOOL ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) override; + size_t ReadBlock(void* buffer, size_t size) override; + FX_BOOL WriteBlock(const void* buffer, + FX_FILESIZE offset, + size_t size) override; + FX_BOOL Flush() override; protected: IFXCRT_FileAccess* m_pFile; @@ -77,7 +61,7 @@ class CFX_CRTFileStream final : public IFX_FileStream { #define FX_MEMSTREAM_TakeOver 0x02 class CFX_MemoryStream final : public IFX_MemoryStream { public: - CFX_MemoryStream(FX_BOOL bConsecutive) + explicit CFX_MemoryStream(FX_BOOL bConsecutive) : m_dwCount(1), m_nTotalSize(0), m_nCurSize(0), @@ -156,7 +140,7 @@ class CFX_MemoryStream final : public IFX_MemoryStream { if (m_nCurPos >= m_nCurSize) { return 0; } - size_t nRead = FX_MIN(size, m_nCurSize - m_nCurPos); + size_t nRead = std::min(size, m_nCurSize - m_nCurPos); if (!ReadBlock(buffer, (int32_t)m_nCurPos, nRead)) { return 0; } @@ -228,12 +212,13 @@ class CFX_MemoryStream final : public IFX_MemoryStream { void EstimateSize(size_t nInitSize, size_t nGrowSize) override { if (m_dwFlags & FX_MEMSTREAM_Consecutive) { if (m_Blocks.GetSize() < 1) { - uint8_t* pBlock = FX_Alloc(uint8_t, FX_MAX(nInitSize, 4096)); + uint8_t* pBlock = + FX_Alloc(uint8_t, std::max(nInitSize, static_cast<size_t>(4096))); m_Blocks.Add(pBlock); } - m_nGrowSize = FX_MAX(nGrowSize, 4096); + m_nGrowSize = std::max(nGrowSize, static_cast<size_t>(4096)); } else if (m_Blocks.GetSize() < 1) { - m_nGrowSize = FX_MAX(nGrowSize, 4096); + m_nGrowSize = std::max(nGrowSize, static_cast<size_t>(4096)); } } uint8_t* GetBuffer() const override { |