From 78b2a931e4e4ff4dc667bc358560e896601c2f50 Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Thu, 1 Oct 2015 22:22:51 -0700 Subject: XFA: Remove checks in fxcrt now that new can't return 0. This is a manual merge. Original review: https://codereview.chromium.org/1052553006 TBR=tsepez@chromium.org Review URL: https://codereview.chromium.org/1384643002 . --- core/include/fxcrt/fx_basic.h | 13 ++----------- core/src/fxcrt/fx_basic_util.cpp | 9 --------- core/src/fxcrt/fx_xml_parser.cpp | 27 ++++----------------------- 3 files changed, 6 insertions(+), 43 deletions(-) diff --git a/core/include/fxcrt/fx_basic.h b/core/include/fxcrt/fx_basic.h index e6b7f69007..62d2a09476 100644 --- a/core/include/fxcrt/fx_basic.h +++ b/core/include/fxcrt/fx_basic.h @@ -956,12 +956,8 @@ class CFX_CountRef { if (m_pObject->m_RefCount <= 0) { delete m_pObject; } - m_pObject = NULL; } m_pObject = new CountedObj; - if (!m_pObject) { - return NULL; - } m_pObject->m_RefCount = 1; return m_pObject; } @@ -1002,17 +998,12 @@ class CFX_CountRef { ObjClass* GetModify() { if (m_pObject == NULL) { m_pObject = new CountedObj; - if (m_pObject) { - m_pObject->m_RefCount = 1; - } + m_pObject->m_RefCount = 1; } else if (m_pObject->m_RefCount > 1) { m_pObject->m_RefCount--; CountedObj* pOldObject = m_pObject; - m_pObject = NULL; m_pObject = new CountedObj(*pOldObject); - if (m_pObject) { - m_pObject->m_RefCount = 1; - } + m_pObject->m_RefCount = 1; } return m_pObject; } diff --git a/core/src/fxcrt/fx_basic_util.cpp b/core/src/fxcrt/fx_basic_util.cpp index 447e169a98..46a0dec1e5 100644 --- a/core/src/fxcrt/fx_basic_util.cpp +++ b/core/src/fxcrt/fx_basic_util.cpp @@ -206,9 +206,6 @@ void* FX_OpenFolder(const FX_CHAR* path) { #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ #ifndef _WIN32_WCE CFindFileDataA* pData = new CFindFileDataA; - if (!pData) { - return NULL; - } #ifdef _FX_WINAPI_PARTITION_DESKTOP_ pData->m_Handle = FindFirstFileA(CFX_ByteString(path) + "/*.*", &pData->m_FindData); @@ -219,9 +216,6 @@ void* FX_OpenFolder(const FX_CHAR* path) { #endif #else CFindFileDataW* pData = new CFindFileDataW; - if (!pData) { - return NULL; - } pData->m_Handle = FindFirstFileW(CFX_WideString::FromLocal(path) + L"/*.*", &pData->m_FindData); #endif @@ -239,9 +233,6 @@ void* FX_OpenFolder(const FX_CHAR* path) { void* FX_OpenFolder(const FX_WCHAR* path) { #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ CFindFileDataW* pData = new CFindFileDataW; - if (!pData) { - return NULL; - } #ifdef _FX_WINAPI_PARTITION_DESKTOP_ pData->m_Handle = FindFirstFileW((CFX_WideString(path) + L"/*.*").c_str(), &pData->m_FindData); diff --git a/core/src/fxcrt/fx_xml_parser.cpp b/core/src/fxcrt/fx_xml_parser.cpp index 6d3c429523..dc59ded2b7 100644 --- a/core/src/fxcrt/fx_xml_parser.cpp +++ b/core/src/fxcrt/fx_xml_parser.cpp @@ -13,16 +13,10 @@ CXML_Parser::~CXML_Parser() { } FX_BOOL CXML_Parser::Init(uint8_t* pBuffer, size_t size) { m_pDataAcc = new CXML_DataBufAcc(pBuffer, size); - if (!m_pDataAcc) { - return FALSE; - } return Init(TRUE); } FX_BOOL CXML_Parser::Init(IFX_FileRead* pFileRead) { m_pDataAcc = new CXML_DataStmAcc(pFileRead); - if (!m_pDataAcc) { - return FALSE; - } return Init(TRUE); } FX_BOOL CXML_Parser::Init(IFX_BufferRead* pBuffer) { @@ -369,15 +363,9 @@ CXML_Element* CXML_Parser::ParseElement(CXML_Element* pParent, if (tag_name.IsEmpty() || bEndTag) { return NULL; } - CXML_Element* pElement; - pElement = new CXML_Element; - if (pElement) { - pElement->m_pParent = pParent; - pElement->SetTag(tag_space, tag_name); - } - if (!pElement) { - return NULL; - } + CXML_Element* pElement = new CXML_Element; + pElement->m_pParent = pParent; + pElement->SetTag(tag_space, tag_name); do { CFX_ByteString attr_space, attr_name; while (m_dwIndex < m_dwBufferSize) { @@ -522,11 +510,7 @@ void CXML_Parser::InsertContentSegment(FX_BOOL bCDATA, if (content.IsEmpty()) { return; } - CXML_Content* pContent; - pContent = new CXML_Content; - if (!pContent) { - return; - } + CXML_Content* pContent = new CXML_Content; pContent->Set(bCDATA, content); pElement->m_Children.Add((void*)CXML_Element::Content); pElement->m_Children.Add(pContent); @@ -807,9 +791,6 @@ void CXML_AttrMap::SetAt(const CFX_ByteStringC& space, if (!m_pMap) { m_pMap = new CFX_ObjectArray; } - if (!m_pMap) { - return; - } CXML_AttrItem* pItem = (CXML_AttrItem*)m_pMap->AddSpace(); if (!pItem) { return; -- cgit v1.2.3