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

Side by Side Diff: core/src/fxcrt/extension.h

Issue 1143663008: Merge to XFA: Remove FX_Alloc() null checks now that it can't return NULL. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: Rebased. Created 5 years, 7 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/fxcodec/codec/fx_codec_jpx_opj.cpp ('k') | core/src/fxcrt/fx_basic_array.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 #ifndef _FXCRT_EXTENSION_IMP_ 7 #ifndef _FXCRT_EXTENSION_IMP_
8 #define _FXCRT_EXTENSION_IMP_ 8 #define _FXCRT_EXTENSION_IMP_
9 9
10 #include "fx_safe_types.h" 10 #include "fx_safe_types.h"
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 } 379 }
380 virtual FX_BOOL IsConsecutive() const FX_OVERRI DE 380 virtual FX_BOOL IsConsecutive() const FX_OVERRI DE
381 { 381 {
382 return m_dwFlags & FX_MEMSTREAM_Consecutive; 382 return m_dwFlags & FX_MEMSTREAM_Consecutive;
383 } 383 }
384 virtual void EstimateSize(size_t nInitSize, s ize_t nGrowSize) FX_OVERRIDE 384 virtual void EstimateSize(size_t nInitSize, s ize_t nGrowSize) FX_OVERRIDE
385 { 385 {
386 if (m_dwFlags & FX_MEMSTREAM_Consecutive) { 386 if (m_dwFlags & FX_MEMSTREAM_Consecutive) {
387 if (m_Blocks.GetSize() < 1) { 387 if (m_Blocks.GetSize() < 1) {
388 FX_LPBYTE pBlock = FX_Alloc(FX_BYTE, FX_MAX(nInitSize, 4096)); 388 FX_LPBYTE pBlock = FX_Alloc(FX_BYTE, FX_MAX(nInitSize, 4096));
389 if (pBlock) { 389 m_Blocks.Add(pBlock);
390 m_Blocks.Add(pBlock);
391 }
392 } 390 }
393 m_nGrowSize = FX_MAX(nGrowSize, 4096); 391 m_nGrowSize = FX_MAX(nGrowSize, 4096);
394 } else if (m_Blocks.GetSize() < 1) { 392 } else if (m_Blocks.GetSize() < 1) {
395 m_nGrowSize = FX_MAX(nGrowSize, 4096); 393 m_nGrowSize = FX_MAX(nGrowSize, 4096);
396 } 394 }
397 } 395 }
398 virtual FX_LPBYTE GetBuffer() const FX_OVERRIDE 396 virtual FX_LPBYTE GetBuffer() const FX_OVERRIDE
399 { 397 {
400 return m_Blocks.GetSize() ? (FX_LPBYTE)m_Blocks[0] : NULL; 398 return m_Blocks.GetSize() ? (FX_LPBYTE)m_Blocks[0] : NULL;
401 } 399 }
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
438 m_nCurSize = size; 436 m_nCurSize = size;
439 } 437 }
440 if (size <= m_nTotalSize) { 438 if (size <= m_nTotalSize) {
441 return TRUE; 439 return TRUE;
442 } 440 }
443 FX_INT32 iCount = m_Blocks.GetSize(); 441 FX_INT32 iCount = m_Blocks.GetSize();
444 size = (size - m_nTotalSize + m_nGrowSize - 1) / m_nGrowSize; 442 size = (size - m_nTotalSize + m_nGrowSize - 1) / m_nGrowSize;
445 m_Blocks.SetSize(m_Blocks.GetSize() + (FX_INT32)size); 443 m_Blocks.SetSize(m_Blocks.GetSize() + (FX_INT32)size);
446 while (size --) { 444 while (size --) {
447 FX_LPBYTE pBlock = FX_Alloc(FX_BYTE, m_nGrowSize); 445 FX_LPBYTE pBlock = FX_Alloc(FX_BYTE, m_nGrowSize);
448 if (!pBlock) {
449 return FALSE;
450 }
451 m_Blocks.SetAt(iCount ++, pBlock); 446 m_Blocks.SetAt(iCount ++, pBlock);
452 m_nTotalSize += m_nGrowSize; 447 m_nTotalSize += m_nGrowSize;
453 } 448 }
454 return TRUE; 449 return TRUE;
455 } 450 }
456 }; 451 };
457 #ifdef __cplusplus 452 #ifdef __cplusplus
458 extern "C" { 453 extern "C" {
459 #endif 454 #endif
460 #define MT_N 848 455 #define MT_N 848
(...skipping 12 matching lines...) Expand all
473 FX_DWORD mt[MT_N]; 468 FX_DWORD mt[MT_N];
474 } FX_MTRANDOMCONTEXT, * FX_LPMTRANDOMCONTEXT; 469 } FX_MTRANDOMCONTEXT, * FX_LPMTRANDOMCONTEXT;
475 typedef FX_MTRANDOMCONTEXT const * FX_LPCMTRANDOMCONTEXT; 470 typedef FX_MTRANDOMCONTEXT const * FX_LPCMTRANDOMCONTEXT;
476 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ 471 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
477 FX_BOOL FX_GenerateCryptoRandom(FX_LPDWORD pBuffer, FX_INT32 iCount); 472 FX_BOOL FX_GenerateCryptoRandom(FX_LPDWORD pBuffer, FX_INT32 iCount);
478 #endif 473 #endif
479 #ifdef __cplusplus 474 #ifdef __cplusplus
480 } 475 }
481 #endif 476 #endif
482 #endif 477 #endif
OLDNEW
« no previous file with comments | « core/src/fxcodec/codec/fx_codec_jpx_opj.cpp ('k') | core/src/fxcrt/fx_basic_array.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698