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

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

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