diff options
author | Tom Sepez <tsepez@chromium.org> | 2015-05-19 14:48:00 -0700 |
---|---|---|
committer | Tom Sepez <tsepez@chromium.org> | 2015-05-19 14:48:00 -0700 |
commit | eb6527763171cdb4b0fbfea5a20d691f4d67b660 (patch) | |
tree | 7781d0fb716b95696b9f411037508244f4cfc28a /core/src/fxcrt | |
parent | 59f4b44d1fbb259967ea518e0bf5fa76b0cc9767 (diff) | |
download | pdfium-eb6527763171cdb4b0fbfea5a20d691f4d67b660.tar.xz |
Remove FX_Alloc() null checks now that it can't return NULL.
This permits some functions to become void's since
they, in turn, can't fail.
R=thestig@chromium.org
Review URL: https://codereview.chromium.org/1142713005
Diffstat (limited to 'core/src/fxcrt')
-rw-r--r-- | core/src/fxcrt/extension.h | 7 | ||||
-rw-r--r-- | core/src/fxcrt/fx_basic_array.cpp | 15 | ||||
-rw-r--r-- | core/src/fxcrt/fx_basic_bstring.cpp | 3 | ||||
-rw-r--r-- | core/src/fxcrt/fx_basic_buffer.cpp | 9 | ||||
-rw-r--r-- | core/src/fxcrt/fx_basic_maps.cpp | 4 | ||||
-rw-r--r-- | core/src/fxcrt/fx_basic_plex.cpp | 3 | ||||
-rw-r--r-- | core/src/fxcrt/fx_basic_wstring.cpp | 3 | ||||
-rw-r--r-- | core/src/fxcrt/fx_extension.cpp | 3 | ||||
-rw-r--r-- | core/src/fxcrt/fxcrt_platforms.cpp | 3 | ||||
-rw-r--r-- | core/src/fxcrt/fxcrt_posix.cpp | 3 | ||||
-rw-r--r-- | core/src/fxcrt/xml_int.h | 3 |
11 files changed, 4 insertions, 52 deletions
diff --git a/core/src/fxcrt/extension.h b/core/src/fxcrt/extension.h index dbee7e676a..c459bdcf99 100644 --- a/core/src/fxcrt/extension.h +++ b/core/src/fxcrt/extension.h @@ -348,9 +348,7 @@ public: if (m_dwFlags & FX_MEMSTREAM_Consecutive) { if (m_Blocks.GetSize() < 1) { FX_LPBYTE pBlock = FX_Alloc(FX_BYTE, FX_MAX(nInitSize, 4096)); - if (pBlock) { - m_Blocks.Add(pBlock); - } + m_Blocks.Add(pBlock); } m_nGrowSize = FX_MAX(nGrowSize, 4096); } else if (m_Blocks.GetSize() < 1) { @@ -407,9 +405,6 @@ protected: m_Blocks.SetSize(m_Blocks.GetSize() + (FX_INT32)size); while (size --) { FX_LPBYTE pBlock = FX_Alloc(FX_BYTE, m_nGrowSize); - if (!pBlock) { - return FALSE; - } m_Blocks.SetAt(iCount ++, pBlock); m_nTotalSize += m_nGrowSize; } diff --git a/core/src/fxcrt/fx_basic_array.cpp b/core/src/fxcrt/fx_basic_array.cpp index 5a2a2e54a1..43a5417c00 100644 --- a/core/src/fxcrt/fx_basic_array.cpp +++ b/core/src/fxcrt/fx_basic_array.cpp @@ -39,10 +39,6 @@ FX_BOOL CFX_BasicArray::SetSize(int nNewSize) return FALSE; } m_pData = FX_Alloc(FX_BYTE, totalSize.ValueOrDie()); - if (!m_pData) { - m_nSize = m_nMaxSize = 0; - return FALSE; - } m_nSize = m_nMaxSize = nNewSize; } else if (nNewSize <= m_nMaxSize) { if (nNewSize > m_nSize) { @@ -197,10 +193,6 @@ void* CFX_BaseSegmentedArray::Add() } if (m_IndexDepth == 0) { void** pIndex = (void**)FX_Alloc(void*, m_IndexSize); - if (pIndex == NULL) { - FX_Free(pSegment); - return NULL; - } pIndex[0] = m_pIndex; pIndex[1] = pSegment; m_pIndex = pIndex; @@ -222,10 +214,6 @@ void* CFX_BaseSegmentedArray::Add() } if (m_DataSize == tree_size * m_SegmentSize) { void** pIndex = (void**)FX_Alloc(void*, m_IndexSize); - if (pIndex == NULL) { - FX_Free(pSegment); - return NULL; - } pIndex[0] = m_pIndex; m_pIndex = pIndex; m_IndexDepth ++; @@ -236,9 +224,6 @@ void* CFX_BaseSegmentedArray::Add() for (i = 1; i < m_IndexDepth; i ++) { if (pSpot[seg_index / tree_size] == NULL) { pSpot[seg_index / tree_size] = (void*)FX_Alloc(void*, m_IndexSize); - if (pSpot[seg_index / tree_size] == NULL) { - break; - } } pSpot = (void**)pSpot[seg_index / tree_size]; seg_index = seg_index % tree_size; diff --git a/core/src/fxcrt/fx_basic_bstring.cpp b/core/src/fxcrt/fx_basic_bstring.cpp index 781b821f00..2377a6d624 100644 --- a/core/src/fxcrt/fx_basic_bstring.cpp +++ b/core/src/fxcrt/fx_basic_bstring.cpp @@ -73,9 +73,6 @@ CFX_ByteString::StringData* CFX_ByteString::StringData::Create(int nLen) FXSYS_assert(usableSize >= nLen); void* pData = FX_Alloc(FX_BYTE, totalSize); - if (!pData) { - return NULL; - } return new (pData) StringData(nLen, usableSize); } CFX_ByteString::~CFX_ByteString() diff --git a/core/src/fxcrt/fx_basic_buffer.cpp b/core/src/fxcrt/fx_basic_buffer.cpp index 7903740e47..06ba9413a5 100644 --- a/core/src/fxcrt/fx_basic_buffer.cpp +++ b/core/src/fxcrt/fx_basic_buffer.cpp @@ -88,10 +88,8 @@ void CFX_BinaryBuf::ExpandBuf(FX_STRSIZE add_size) } else { pNewBuffer = FX_Alloc(FX_BYTE, new_size); } - if (pNewBuffer) { - m_pBuffer = pNewBuffer; - m_AllocSize = new_size; - } + m_pBuffer = pNewBuffer; + m_AllocSize = new_size; } void CFX_BinaryBuf::CopyData(const void* pStr, FX_STRSIZE size) { @@ -456,9 +454,6 @@ FX_INT32 IFX_BufferArchive::AppendBlock(const void* pBuf, size_t size) } if (!m_pBuffer) { m_pBuffer = FX_Alloc(FX_BYTE, m_BufSize); - if (!m_pBuffer) { - return -1; - } } FX_LPBYTE buffer = (FX_LPBYTE)pBuf; FX_STRSIZE temp_size = (FX_STRSIZE)size; diff --git a/core/src/fxcrt/fx_basic_maps.cpp b/core/src/fxcrt/fx_basic_maps.cpp index 8ae44ce6a0..7fca42acde 100644 --- a/core/src/fxcrt/fx_basic_maps.cpp +++ b/core/src/fxcrt/fx_basic_maps.cpp @@ -413,9 +413,7 @@ static void _CompactStringStore(_CompactString* pCompact, FX_LPCBYTE pStr, int l pCompact->m_LenHigh = len / 256; pCompact->m_LenLow = len % 256; pCompact->m_pBuffer = FX_Alloc(FX_BYTE, len); - if (pCompact->m_pBuffer) { - FXSYS_memcpy32(pCompact->m_pBuffer, pStr, len); - } + FXSYS_memcpy32(pCompact->m_pBuffer, pStr, len); } static CFX_ByteStringC _CompactStringGet(_CompactString* pCompact) { diff --git a/core/src/fxcrt/fx_basic_plex.cpp b/core/src/fxcrt/fx_basic_plex.cpp index bff55461f4..78319bd5da 100644 --- a/core/src/fxcrt/fx_basic_plex.cpp +++ b/core/src/fxcrt/fx_basic_plex.cpp @@ -9,9 +9,6 @@ CFX_Plex* CFX_Plex::Create(CFX_Plex*& pHead, FX_DWORD nMax, FX_DWORD cbElement) { CFX_Plex* p = (CFX_Plex*)FX_Alloc(FX_BYTE, sizeof(CFX_Plex) + nMax * cbElement); - if (!p) { - return NULL; - } p->pNext = pHead; pHead = p; return p; diff --git a/core/src/fxcrt/fx_basic_wstring.cpp b/core/src/fxcrt/fx_basic_wstring.cpp index 3c54ca983e..09e64e0c72 100644 --- a/core/src/fxcrt/fx_basic_wstring.cpp +++ b/core/src/fxcrt/fx_basic_wstring.cpp @@ -34,9 +34,6 @@ CFX_WideString::StringData* CFX_WideString::StringData::Create(int nLen) FXSYS_assert(usableLen >= nLen); void* pData = FX_Alloc(FX_BYTE, iSize.ValueOrDie()); - if (!pData) { - return NULL; - } return new (pData) StringData(nLen, usableLen); } CFX_WideString::~CFX_WideString() diff --git a/core/src/fxcrt/fx_extension.cpp b/core/src/fxcrt/fx_extension.cpp index 4790aee00d..20e2e1a320 100644 --- a/core/src/fxcrt/fx_extension.cpp +++ b/core/src/fxcrt/fx_extension.cpp @@ -275,9 +275,6 @@ extern "C" { FX_LPVOID FX_Random_MT_Start(FX_DWORD dwSeed) { FX_LPMTRANDOMCONTEXT pContext = FX_Alloc(FX_MTRANDOMCONTEXT, 1); - if (!pContext) { - return NULL; - } pContext->mt[0] = dwSeed; FX_DWORD &i = pContext->mti; FX_LPDWORD pBuf = pContext->mt; diff --git a/core/src/fxcrt/fxcrt_platforms.cpp b/core/src/fxcrt/fxcrt_platforms.cpp index d9b99624d3..942d6a3c02 100644 --- a/core/src/fxcrt/fxcrt_platforms.cpp +++ b/core/src/fxcrt/fxcrt_platforms.cpp @@ -169,9 +169,6 @@ FX_BOOL FX_File_Copy(FX_BSTR fileNameSrc, FX_BSTR fileNameDst) } FX_FILESIZE num = 0; FX_LPBYTE pBuffer = FX_Alloc(FX_BYTE, 32768); - if (!pBuffer) { - return FALSE; - } while (num = src.Read(pBuffer, 32768)) { if (dst.Write(pBuffer, num) != num) { break; diff --git a/core/src/fxcrt/fxcrt_posix.cpp b/core/src/fxcrt/fxcrt_posix.cpp index 2982435c96..06d92c523d 100644 --- a/core/src/fxcrt/fxcrt_posix.cpp +++ b/core/src/fxcrt/fxcrt_posix.cpp @@ -165,9 +165,6 @@ FX_BOOL FX_File_Copy(FX_BSTR fileNameSrc, FX_BSTR fileNameDst) } size_t num = 0; FX_LPBYTE pBuffer = FX_Alloc(FX_BYTE, 32768); - if (!pBuffer) { - return FALSE; - } num = src.Read(pBuffer, 32768); while (num) { if (dst.Write(pBuffer, num) != num) { diff --git a/core/src/fxcrt/xml_int.h b/core/src/fxcrt/xml_int.h index 964c7944d1..f0a2485163 100644 --- a/core/src/fxcrt/xml_int.h +++ b/core/src/fxcrt/xml_int.h @@ -107,9 +107,6 @@ public: m_dwSize = (size_t)FX_MIN(FX_XMLDATASTREAM_BufferSize, nLength - m_nStart); if (!m_pBuffer) { m_pBuffer = FX_Alloc(FX_BYTE, m_dwSize); - if (!m_pBuffer) { - return FALSE; - } } return m_pFileRead->ReadBlock(m_pBuffer, m_nStart, m_dwSize); } |