From d50b172a9d3a05704748f0798b5aaa422485abbd Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Wed, 20 May 2015 09:50:37 -0700 Subject: Merge to XFA: Remove FX_Alloc() null checks now that it can't return NULL. Original Review URL: https://codereview.chromium.org/1142713005 R=thestig@chromium.org TBR=thestig@chromium.org Review URL: https://codereview.chromium.org/1143663008 --- core/src/fxcrt/extension.h | 7 +------ core/src/fxcrt/fx_basic_array.cpp | 15 --------------- core/src/fxcrt/fx_basic_bstring.cpp | 3 --- core/src/fxcrt/fx_basic_buffer.cpp | 9 ++------- core/src/fxcrt/fx_basic_maps.cpp | 4 +--- core/src/fxcrt/fx_basic_plex.cpp | 3 --- core/src/fxcrt/fx_basic_wstring.cpp | 3 --- core/src/fxcrt/fx_extension.cpp | 3 --- core/src/fxcrt/fxcrt_platforms.cpp | 3 --- core/src/fxcrt/fxcrt_posix.cpp | 3 --- core/src/fxcrt/xml_int.h | 3 --- 11 files changed, 4 insertions(+), 52 deletions(-) (limited to 'core/src/fxcrt') diff --git a/core/src/fxcrt/extension.h b/core/src/fxcrt/extension.h index bda7f62297..115b15b674 100644 --- a/core/src/fxcrt/extension.h +++ b/core/src/fxcrt/extension.h @@ -386,9 +386,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) { @@ -445,9 +443,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 e74c52d4a8..876cf47548 100644 --- a/core/src/fxcrt/fx_extension.cpp +++ b/core/src/fxcrt/fx_extension.cpp @@ -287,9 +287,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 cdf3d421f5..0781ba436c 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 98f9a71c6c..5bc2dd44d2 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); } -- cgit v1.2.3