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

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

Issue 1142713005: Remove FX_Alloc() null checks now that it can't return NULL. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Fix missing FX_Alloc2D, check overflow on add, remove unused enum. 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 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 } 341 }
342 virtual FX_BOOL IsConsecutive() const FX_OVERRI DE 342 virtual FX_BOOL IsConsecutive() const FX_OVERRI DE
343 { 343 {
344 return m_dwFlags & FX_MEMSTREAM_Consecutive; 344 return m_dwFlags & FX_MEMSTREAM_Consecutive;
345 } 345 }
346 virtual void EstimateSize(size_t nInitSize, s ize_t nGrowSize) FX_OVERRIDE 346 virtual void EstimateSize(size_t nInitSize, s ize_t nGrowSize) FX_OVERRIDE
347 { 347 {
348 if (m_dwFlags & FX_MEMSTREAM_Consecutive) { 348 if (m_dwFlags & FX_MEMSTREAM_Consecutive) {
349 if (m_Blocks.GetSize() < 1) { 349 if (m_Blocks.GetSize() < 1) {
350 FX_LPBYTE pBlock = FX_Alloc(FX_BYTE, FX_MAX(nInitSize, 4096)); 350 FX_LPBYTE pBlock = FX_Alloc(FX_BYTE, FX_MAX(nInitSize, 4096));
351 if (pBlock) { 351 m_Blocks.Add(pBlock);
352 m_Blocks.Add(pBlock);
353 }
354 } 352 }
355 m_nGrowSize = FX_MAX(nGrowSize, 4096); 353 m_nGrowSize = FX_MAX(nGrowSize, 4096);
356 } else if (m_Blocks.GetSize() < 1) { 354 } else if (m_Blocks.GetSize() < 1) {
357 m_nGrowSize = FX_MAX(nGrowSize, 4096); 355 m_nGrowSize = FX_MAX(nGrowSize, 4096);
358 } 356 }
359 } 357 }
360 virtual FX_LPBYTE GetBuffer() const FX_OVERRIDE 358 virtual FX_LPBYTE GetBuffer() const FX_OVERRIDE
361 { 359 {
362 return m_Blocks.GetSize() ? (FX_LPBYTE)m_Blocks[0] : NULL; 360 return m_Blocks.GetSize() ? (FX_LPBYTE)m_Blocks[0] : NULL;
363 } 361 }
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
400 m_nCurSize = size; 398 m_nCurSize = size;
401 } 399 }
402 if (size <= m_nTotalSize) { 400 if (size <= m_nTotalSize) {
403 return TRUE; 401 return TRUE;
404 } 402 }
405 FX_INT32 iCount = m_Blocks.GetSize(); 403 FX_INT32 iCount = m_Blocks.GetSize();
406 size = (size - m_nTotalSize + m_nGrowSize - 1) / m_nGrowSize; 404 size = (size - m_nTotalSize + m_nGrowSize - 1) / m_nGrowSize;
407 m_Blocks.SetSize(m_Blocks.GetSize() + (FX_INT32)size); 405 m_Blocks.SetSize(m_Blocks.GetSize() + (FX_INT32)size);
408 while (size --) { 406 while (size --) {
409 FX_LPBYTE pBlock = FX_Alloc(FX_BYTE, m_nGrowSize); 407 FX_LPBYTE pBlock = FX_Alloc(FX_BYTE, m_nGrowSize);
410 if (!pBlock) {
411 return FALSE;
412 }
413 m_Blocks.SetAt(iCount ++, pBlock); 408 m_Blocks.SetAt(iCount ++, pBlock);
414 m_nTotalSize += m_nGrowSize; 409 m_nTotalSize += m_nGrowSize;
415 } 410 }
416 return TRUE; 411 return TRUE;
417 } 412 }
418 }; 413 };
419 #ifdef __cplusplus 414 #ifdef __cplusplus
420 extern "C" { 415 extern "C" {
421 #endif 416 #endif
422 #define MT_N 848 417 #define MT_N 848
(...skipping 12 matching lines...) Expand all
435 FX_DWORD mt[MT_N]; 430 FX_DWORD mt[MT_N];
436 } FX_MTRANDOMCONTEXT, * FX_LPMTRANDOMCONTEXT; 431 } FX_MTRANDOMCONTEXT, * FX_LPMTRANDOMCONTEXT;
437 typedef FX_MTRANDOMCONTEXT const * FX_LPCMTRANDOMCONTEXT; 432 typedef FX_MTRANDOMCONTEXT const * FX_LPCMTRANDOMCONTEXT;
438 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ 433 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
439 FX_BOOL FX_GenerateCryptoRandom(FX_LPDWORD pBuffer, FX_INT32 iCount); 434 FX_BOOL FX_GenerateCryptoRandom(FX_LPDWORD pBuffer, FX_INT32 iCount);
440 #endif 435 #endif
441 #ifdef __cplusplus 436 #ifdef __cplusplus
442 } 437 }
443 #endif 438 #endif
444 #endif 439 #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