Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1131)

Unified Diff: core/src/fxcrt/extension.h

Issue 1567343002: Switch most min/max macros to std::min/max. (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: actually compile Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « core/src/fpdftext/fpdf_text_int.cpp ('k') | core/src/fxcrt/fx_basic_buffer.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: core/src/fxcrt/extension.h
diff --git a/core/src/fxcrt/extension.h b/core/src/fxcrt/extension.h
index 58b0457a7cd67a95a18655855ead6147fd947cdf..fbf040d40d7ea7cd636fdfda04abb6fd4b9043eb 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 {
« no previous file with comments | « core/src/fpdftext/fpdf_text_int.cpp ('k') | core/src/fxcrt/fx_basic_buffer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698