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

Side by Side Diff: core/src/fxcrt/fx_basic_buffer.cpp

Issue 1577503002: Merge to XFA: Switch most min/max macros to std::min/max. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: rebase 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 unified diff | Download patch
« no previous file with comments | « core/src/fxcrt/extension.h ('k') | core/src/fxcrt/fx_basic_wstring.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include <algorithm>
8
7 #include "core/include/fxcrt/fx_basic.h" 9 #include "core/include/fxcrt/fx_basic.h"
8 10
9 FX_STRSIZE FX_ftoa(FX_FLOAT f, FX_CHAR* buf); 11 FX_STRSIZE FX_ftoa(FX_FLOAT f, FX_CHAR* buf);
10 CFX_BinaryBuf::CFX_BinaryBuf() 12 CFX_BinaryBuf::CFX_BinaryBuf()
11 : m_AllocStep(0), m_pBuffer(NULL), m_DataSize(0), m_AllocSize(0) {} 13 : m_AllocStep(0), m_pBuffer(NULL), m_DataSize(0), m_AllocSize(0) {}
12 CFX_BinaryBuf::CFX_BinaryBuf(FX_STRSIZE size) 14 CFX_BinaryBuf::CFX_BinaryBuf(FX_STRSIZE size)
13 : m_AllocStep(0), m_DataSize(size), m_AllocSize(size) { 15 : m_AllocStep(0), m_DataSize(size), m_AllocSize(size) {
14 m_pBuffer = FX_Alloc(uint8_t, size); 16 m_pBuffer = FX_Alloc(uint8_t, size);
15 } 17 }
16 CFX_BinaryBuf::~CFX_BinaryBuf() { 18 CFX_BinaryBuf::~CFX_BinaryBuf() {
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 int32_t IFX_BufferArchive::AppendBlock(const void* pBuf, size_t size) { 396 int32_t IFX_BufferArchive::AppendBlock(const void* pBuf, size_t size) {
395 if (!pBuf || size < 1) { 397 if (!pBuf || size < 1) {
396 return 0; 398 return 0;
397 } 399 }
398 if (!m_pBuffer) { 400 if (!m_pBuffer) {
399 m_pBuffer = FX_Alloc(uint8_t, m_BufSize); 401 m_pBuffer = FX_Alloc(uint8_t, m_BufSize);
400 } 402 }
401 uint8_t* buffer = (uint8_t*)pBuf; 403 uint8_t* buffer = (uint8_t*)pBuf;
402 FX_STRSIZE temp_size = (FX_STRSIZE)size; 404 FX_STRSIZE temp_size = (FX_STRSIZE)size;
403 while (temp_size > 0) { 405 while (temp_size > 0) {
404 FX_STRSIZE buf_size = FX_MIN(m_BufSize - m_Length, (FX_STRSIZE)temp_size); 406 FX_STRSIZE buf_size = std::min(m_BufSize - m_Length, (FX_STRSIZE)temp_size);
405 FXSYS_memcpy(m_pBuffer + m_Length, buffer, buf_size); 407 FXSYS_memcpy(m_pBuffer + m_Length, buffer, buf_size);
406 m_Length += buf_size; 408 m_Length += buf_size;
407 if (m_Length == m_BufSize) { 409 if (m_Length == m_BufSize) {
408 if (!Flush()) { 410 if (!Flush()) {
409 return -1; 411 return -1;
410 } 412 }
411 } 413 }
412 temp_size -= buf_size; 414 temp_size -= buf_size;
413 buffer += buf_size; 415 buffer += buf_size;
414 } 416 }
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
452 } 454 }
453 FX_BOOL CFX_FileBufferArchive::DoWork(const void* pBuf, size_t size) { 455 FX_BOOL CFX_FileBufferArchive::DoWork(const void* pBuf, size_t size) {
454 if (!m_pFile) { 456 if (!m_pFile) {
455 return FALSE; 457 return FALSE;
456 } 458 }
457 if (!pBuf || size < 1) { 459 if (!pBuf || size < 1) {
458 return TRUE; 460 return TRUE;
459 } 461 }
460 return m_pFile->WriteBlock(pBuf, size); 462 return m_pFile->WriteBlock(pBuf, size);
461 } 463 }
OLDNEW
« no previous file with comments | « core/src/fxcrt/extension.h ('k') | core/src/fxcrt/fx_basic_wstring.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698