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

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

Issue 1252613002: FX_BOOL considered harmful. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Manual edits. Created 5 years, 5 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/fx_basic_bstring.cpp ('k') | core/src/fxcrt/fx_basic_coords.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 "../../include/fxcrt/fx_basic.h" 7 #include "../../include/fxcrt/fx_basic.h"
8 FX_STRSIZE FX_ftoa(FX_FLOAT f, FX_CHAR* buf); 8 FX_STRSIZE FX_ftoa(FX_FLOAT f, FX_CHAR* buf);
9 CFX_BinaryBuf::CFX_BinaryBuf() 9 CFX_BinaryBuf::CFX_BinaryBuf()
10 : m_AllocStep(0) 10 : m_AllocStep(0)
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 } else { 314 } else {
315 m_SavingBuf.AppendBlock(pData, dwSize); 315 m_SavingBuf.AppendBlock(pData, dwSize);
316 } 316 }
317 } 317 }
318 CFX_ArchiveLoader::CFX_ArchiveLoader(const uint8_t* pData, FX_DWORD dwSize) 318 CFX_ArchiveLoader::CFX_ArchiveLoader(const uint8_t* pData, FX_DWORD dwSize)
319 { 319 {
320 m_pLoadingBuf = pData; 320 m_pLoadingBuf = pData;
321 m_LoadingPos = 0; 321 m_LoadingPos = 0;
322 m_LoadingSize = dwSize; 322 m_LoadingSize = dwSize;
323 } 323 }
324 FX_BOOL CFX_ArchiveLoader::IsEOF() 324 bool CFX_ArchiveLoader::IsEOF()
325 { 325 {
326 return m_LoadingPos >= m_LoadingSize; 326 return m_LoadingPos >= m_LoadingSize;
327 } 327 }
328 CFX_ArchiveLoader& CFX_ArchiveLoader::operator >> (uint8_t& i) 328 CFX_ArchiveLoader& CFX_ArchiveLoader::operator >> (uint8_t& i)
329 { 329 {
330 if (m_LoadingPos >= m_LoadingSize) { 330 if (m_LoadingPos >= m_LoadingSize) {
331 return *this; 331 return *this;
332 } 332 }
333 i = m_pLoadingBuf[m_LoadingPos++]; 333 i = m_pLoadingBuf[m_LoadingPos++];
334 return *this; 334 return *this;
(...skipping 30 matching lines...) Expand all
365 m_LoadingPos += len; 365 m_LoadingPos += len;
366 return *this; 366 return *this;
367 } 367 }
368 CFX_ArchiveLoader& CFX_ArchiveLoader::operator >> (CFX_WideString& str) 368 CFX_ArchiveLoader& CFX_ArchiveLoader::operator >> (CFX_WideString& str)
369 { 369 {
370 CFX_ByteString encoded; 370 CFX_ByteString encoded;
371 operator >> (encoded); 371 operator >> (encoded);
372 str = CFX_WideString::FromUTF16LE((const unsigned short*)encoded.c_str(), en coded.GetLength()); 372 str = CFX_WideString::FromUTF16LE((const unsigned short*)encoded.c_str(), en coded.GetLength());
373 return *this; 373 return *this;
374 } 374 }
375 FX_BOOL CFX_ArchiveLoader::Read(void* pBuf, FX_DWORD dwSize) 375 bool CFX_ArchiveLoader::Read(void* pBuf, FX_DWORD dwSize)
376 { 376 {
377 if (m_LoadingPos + dwSize > m_LoadingSize) { 377 if (m_LoadingPos + dwSize > m_LoadingSize) {
378 return FALSE; 378 return false;
379 } 379 }
380 FXSYS_memcpy(pBuf, m_pLoadingBuf + m_LoadingPos, dwSize); 380 FXSYS_memcpy(pBuf, m_pLoadingBuf + m_LoadingPos, dwSize);
381 m_LoadingPos += dwSize; 381 m_LoadingPos += dwSize;
382 return TRUE; 382 return true;
383 } 383 }
384 void CFX_BitStream::Init(const uint8_t* pData, FX_DWORD dwSize) 384 void CFX_BitStream::Init(const uint8_t* pData, FX_DWORD dwSize)
385 { 385 {
386 m_pData = pData; 386 m_pData = pData;
387 m_BitSize = dwSize * 8; 387 m_BitSize = dwSize * 8;
388 m_BitPos = 0; 388 m_BitPos = 0;
389 } 389 }
390 void CFX_BitStream::ByteAlign() 390 void CFX_BitStream::ByteAlign()
391 { 391 {
392 int mod = m_BitPos % 8; 392 int mod = m_BitPos % 8;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
434 { 434 {
435 } 435 }
436 void IFX_BufferArchive::Clear() 436 void IFX_BufferArchive::Clear()
437 { 437 {
438 m_Length = 0; 438 m_Length = 0;
439 if (m_pBuffer) { 439 if (m_pBuffer) {
440 FX_Free(m_pBuffer); 440 FX_Free(m_pBuffer);
441 m_pBuffer = NULL; 441 m_pBuffer = NULL;
442 } 442 }
443 } 443 }
444 FX_BOOL IFX_BufferArchive::Flush() 444 bool IFX_BufferArchive::Flush()
445 { 445 {
446 FX_BOOL bRet = DoWork(m_pBuffer, m_Length); 446 bool bRet = DoWork(m_pBuffer, m_Length);
447 m_Length = 0; 447 m_Length = 0;
448 return bRet; 448 return bRet;
449 } 449 }
450 int32_t IFX_BufferArchive::AppendBlock(const void* pBuf, size_t size) 450 int32_t IFX_BufferArchive::AppendBlock(const void* pBuf, size_t size)
451 { 451 {
452 if (!pBuf || size < 1) { 452 if (!pBuf || size < 1) {
453 return 0; 453 return 0;
454 } 454 }
455 if (!m_pBuffer) { 455 if (!m_pBuffer) {
456 m_pBuffer = FX_Alloc(uint8_t, m_BufSize); 456 m_pBuffer = FX_Alloc(uint8_t, m_BufSize);
(...skipping 24 matching lines...) Expand all
481 FXSYS_itoa(i, buf, 10); 481 FXSYS_itoa(i, buf, 10);
482 return AppendBlock(buf, (size_t)FXSYS_strlen(buf)); 482 return AppendBlock(buf, (size_t)FXSYS_strlen(buf));
483 } 483 }
484 int32_t IFX_BufferArchive::AppendString(const CFX_ByteStringC& lpsz) 484 int32_t IFX_BufferArchive::AppendString(const CFX_ByteStringC& lpsz)
485 { 485 {
486 return AppendBlock(lpsz.GetPtr(), lpsz.GetLength()); 486 return AppendBlock(lpsz.GetPtr(), lpsz.GetLength());
487 } 487 }
488 CFX_FileBufferArchive::CFX_FileBufferArchive(FX_STRSIZE size) 488 CFX_FileBufferArchive::CFX_FileBufferArchive(FX_STRSIZE size)
489 : IFX_BufferArchive(size) 489 : IFX_BufferArchive(size)
490 , m_pFile(NULL) 490 , m_pFile(NULL)
491 , m_bTakeover(FALSE) 491 , m_bTakeover(false)
492 { 492 {
493 } 493 }
494 CFX_FileBufferArchive::~CFX_FileBufferArchive() 494 CFX_FileBufferArchive::~CFX_FileBufferArchive()
495 { 495 {
496 Clear(); 496 Clear();
497 } 497 }
498 void CFX_FileBufferArchive::Clear() 498 void CFX_FileBufferArchive::Clear()
499 { 499 {
500 if (m_pFile && m_bTakeover) { 500 if (m_pFile && m_bTakeover) {
501 m_pFile->Release(); 501 m_pFile->Release();
502 } 502 }
503 m_pFile = NULL; 503 m_pFile = NULL;
504 m_bTakeover = FALSE; 504 m_bTakeover = false;
505 IFX_BufferArchive::Clear(); 505 IFX_BufferArchive::Clear();
506 } 506 }
507 FX_BOOL CFX_FileBufferArchive::AttachFile(IFX_StreamWrite *pFile, FX_BOOL bTakeo ver ) 507 bool CFX_FileBufferArchive::AttachFile(IFX_StreamWrite *pFile, bool bTakeover )
508 { 508 {
509 if (!pFile) { 509 if (!pFile) {
510 return FALSE; 510 return false;
511 } 511 }
512 if (m_pFile && m_bTakeover) { 512 if (m_pFile && m_bTakeover) {
513 m_pFile->Release(); 513 m_pFile->Release();
514 } 514 }
515 m_pFile = pFile; 515 m_pFile = pFile;
516 m_bTakeover = bTakeover; 516 m_bTakeover = bTakeover;
517 return TRUE; 517 return true;
518 } 518 }
519 FX_BOOL CFX_FileBufferArchive::AttachFile(const FX_WCHAR* filename) 519 bool CFX_FileBufferArchive::AttachFile(const FX_WCHAR* filename)
520 { 520 {
521 if (!filename) { 521 if (!filename) {
522 return FALSE; 522 return false;
523 } 523 }
524 if (m_pFile && m_bTakeover) { 524 if (m_pFile && m_bTakeover) {
525 m_pFile->Release(); 525 m_pFile->Release();
526 } 526 }
527 m_pFile = FX_CreateFileWrite(filename); 527 m_pFile = FX_CreateFileWrite(filename);
528 if (!m_pFile) { 528 if (!m_pFile) {
529 return FALSE; 529 return false;
530 } 530 }
531 m_bTakeover = TRUE; 531 m_bTakeover = true;
532 return TRUE; 532 return true;
533 } 533 }
534 FX_BOOL CFX_FileBufferArchive::AttachFile(const FX_CHAR* filename) 534 bool CFX_FileBufferArchive::AttachFile(const FX_CHAR* filename)
535 { 535 {
536 if (!filename) { 536 if (!filename) {
537 return FALSE; 537 return false;
538 } 538 }
539 if (m_pFile && m_bTakeover) { 539 if (m_pFile && m_bTakeover) {
540 m_pFile->Release(); 540 m_pFile->Release();
541 } 541 }
542 m_pFile = FX_CreateFileWrite(filename); 542 m_pFile = FX_CreateFileWrite(filename);
543 if (!m_pFile) { 543 if (!m_pFile) {
544 return FALSE; 544 return false;
545 } 545 }
546 m_bTakeover = TRUE; 546 m_bTakeover = true;
547 return TRUE; 547 return true;
548 } 548 }
549 FX_BOOL CFX_FileBufferArchive::DoWork(const void* pBuf, size_t size) 549 bool CFX_FileBufferArchive::DoWork(const void* pBuf, size_t size)
550 { 550 {
551 if (!m_pFile) { 551 if (!m_pFile) {
552 return FALSE; 552 return false;
553 } 553 }
554 if (!pBuf || size < 1) { 554 if (!pBuf || size < 1) {
555 return TRUE; 555 return true;
556 } 556 }
557 return m_pFile->WriteBlock(pBuf, size); 557 return m_pFile->WriteBlock(pBuf, size);
558 } 558 }
OLDNEW
« no previous file with comments | « core/src/fxcrt/fx_basic_bstring.cpp ('k') | core/src/fxcrt/fx_basic_coords.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698