Fix all remaining instances of FX_NEW.

R=thestig@chromium.org

Review URL: https://codereview.chromium.org/1084613006
diff --git a/core/include/fpdfapi/fpdf_objects.h b/core/include/fpdfapi/fpdf_objects.h
index df5803c..0315465 100644
--- a/core/include/fpdfapi/fpdf_objects.h
+++ b/core/include/fpdfapi/fpdf_objects.h
@@ -113,7 +113,7 @@
 
     static CPDF_Boolean*	Create(FX_BOOL value)
     {
-        return FX_NEW CPDF_Boolean(value);
+        return new CPDF_Boolean(value);
     }
 
     CPDF_Boolean() : CPDF_Object(PDFOBJ_BOOLEAN), m_bValue(false) { }
@@ -134,22 +134,22 @@
 
     static CPDF_Number*		Create(int value)
     {
-        return FX_NEW CPDF_Number(value);
+        return new CPDF_Number(value);
     }
 
     static CPDF_Number*		Create(FX_FLOAT value)
     {
-        return FX_NEW CPDF_Number(value);
+        return new CPDF_Number(value);
     }
 
     static CPDF_Number*		Create(FX_BSTR str)
     {
-        return FX_NEW CPDF_Number(str);
+        return new CPDF_Number(str);
     }
 
     static CPDF_Number*		Create(FX_BOOL bInteger, void* pData)
     {
-        return FX_NEW CPDF_Number(bInteger, pData);
+        return new CPDF_Number(bInteger, pData);
     }
 
     CPDF_Number() : CPDF_Object(PDFOBJ_NUMBER), m_bInteger(false), m_Integer(0) { }
@@ -212,12 +212,12 @@
 
     static CPDF_String*		Create(const CFX_ByteString& str, FX_BOOL bHex = FALSE)
     {
-        return FX_NEW CPDF_String(str, bHex);
+        return new CPDF_String(str, bHex);
     }
 
     static CPDF_String*		Create(const CFX_WideString& str)
     {
-        return FX_NEW CPDF_String(str);
+        return new CPDF_String(str);
     }
 
     CPDF_String() : CPDF_Object(PDFOBJ_STRING), m_bHex(FALSE) { }
@@ -255,17 +255,17 @@
 
     static CPDF_Name*		Create(const CFX_ByteString& str)
     {
-        return FX_NEW CPDF_Name(str);
+        return new CPDF_Name(str);
     }
 
     static CPDF_Name*		Create(FX_BSTR str)
     {
-        return FX_NEW CPDF_Name(str);
+        return new CPDF_Name(str);
     }
 
     static CPDF_Name*		Create(FX_LPCSTR str)
     {
-        return FX_NEW CPDF_Name(str);
+        return new CPDF_Name(str);
     }
 
     CPDF_Name(const CFX_ByteString& str) : CPDF_Object(PDFOBJ_NAME), m_Name(str) { }
@@ -292,7 +292,7 @@
 
     static CPDF_Array*		Create()
     {
-        return FX_NEW CPDF_Array();
+        return new CPDF_Array();
     }
 
     CPDF_Array() : CPDF_Object(PDFOBJ_ARRAY) { }
@@ -389,7 +389,7 @@
 
     static CPDF_Dictionary*	Create()
     {
-        return FX_NEW CPDF_Dictionary();
+        return new CPDF_Dictionary();
     }
 
     CPDF_Dictionary() : CPDF_Object(PDFOBJ_DICTIONARY) { }
@@ -506,7 +506,7 @@
 
     static CPDF_Stream*		Create(FX_LPBYTE pData, FX_DWORD size, CPDF_Dictionary* pDict)
     {
-        return FX_NEW CPDF_Stream(pData, size, pDict);
+        return new CPDF_Stream(pData, size, pDict);
     }
 
     CPDF_Stream(FX_LPBYTE pData, FX_DWORD size, CPDF_Dictionary* pDict);
@@ -664,7 +664,7 @@
 
     static CPDF_Null*		Create()
     {
-        return FX_NEW CPDF_Null();
+        return new CPDF_Null();
     }
 
     CPDF_Null() : CPDF_Object(PDFOBJ_NULL) { }
@@ -675,7 +675,7 @@
 
     static CPDF_Reference*	Create(CPDF_IndirectObjects* pDoc, int objnum)
     {
-        return FX_NEW CPDF_Reference(pDoc, objnum);
+        return new CPDF_Reference(pDoc, objnum);
     }
 
     CPDF_Reference(CPDF_IndirectObjects* pDoc, int objnum)
diff --git a/core/include/fxcrt/fx_memory.h b/core/include/fxcrt/fx_memory.h
index 4d567360..4e7c501 100644
--- a/core/include/fxcrt/fx_memory.h
+++ b/core/include/fxcrt/fx_memory.h
@@ -25,7 +25,7 @@
 }
 
 #define FX_NEW new
-#define FX_NEW_VECTOR(Pointer, Class, Count) (Pointer = FX_NEW Class[Count])
+#define FX_NEW_VECTOR(Pointer, Class, Count) (Pointer = new Class[Count])
 #define FX_DELETE_VECTOR(Pointer, Class, Count) delete[] Pointer
 
 class CFX_DestructObject 
diff --git a/core/src/fxcrt/fx_arabic.cpp b/core/src/fxcrt/fx_arabic.cpp
index 583ce81..04ce172 100644
--- a/core/src/fxcrt/fx_arabic.cpp
+++ b/core/src/fxcrt/fx_arabic.cpp
@@ -9,7 +9,7 @@
 extern const FX_DWORD gs_FX_TextLayout_CodeProperties[65536];
 IFX_BidiChar* IFX_BidiChar::Create()
 {
-    return FX_NEW CFX_BidiChar;
+    return new CFX_BidiChar;
 }
 CFX_BidiChar::CFX_BidiChar()
     : m_bSeparateNeutral(TRUE)
diff --git a/core/src/fxcrt/fx_extension.cpp b/core/src/fxcrt/fx_extension.cpp
index 6e82ab3..4790aee 100644
--- a/core/src/fxcrt/fx_extension.cpp
+++ b/core/src/fxcrt/fx_extension.cpp
@@ -90,7 +90,7 @@
         pFA->Release();
         return NULL;
     }
-    return FX_NEW CFX_CRTFileStream(pFA);
+    return new CFX_CRTFileStream(pFA);
 }
 IFX_FileStream* FX_CreateFileStream(FX_LPCWSTR filename, FX_DWORD dwModes)
 {
@@ -102,7 +102,7 @@
         pFA->Release();
         return NULL;
     }
-    return FX_NEW CFX_CRTFileStream(pFA);
+    return new CFX_CRTFileStream(pFA);
 }
 IFX_FileWrite* FX_CreateFileWrite(FX_LPCSTR filename)
 {
@@ -122,11 +122,11 @@
 }
 IFX_MemoryStream* FX_CreateMemoryStream(FX_LPBYTE pBuffer, size_t dwSize, FX_BOOL bTakeOver)
 {
-    return FX_NEW CFX_MemoryStream(pBuffer, dwSize, bTakeOver);
+    return new CFX_MemoryStream(pBuffer, dwSize, bTakeOver);
 }
 IFX_MemoryStream* FX_CreateMemoryStream(FX_BOOL bConsecutive)
 {
-    return FX_NEW CFX_MemoryStream(bConsecutive);
+    return new CFX_MemoryStream(bConsecutive);
 }
 #ifdef __cplusplus
 extern "C" {
diff --git a/core/src/fxcrt/fxcrt_platforms.cpp b/core/src/fxcrt/fxcrt_platforms.cpp
index cdf3d42..d9b9962 100644
--- a/core/src/fxcrt/fxcrt_platforms.cpp
+++ b/core/src/fxcrt/fxcrt_platforms.cpp
@@ -9,7 +9,7 @@
 #if (_FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ && _FXM_PLATFORM_ != _FXM_PLATFORM_LINUX_ && _FXM_PLATFORM_ != _FXM_PLATFORM_APPLE_ && _FXM_PLATFORM_ != _FXM_PLATFORM_ANDROID_)
 IFXCRT_FileAccess* FXCRT_FileAccess_Create()
 {
-    return FX_NEW CFXCRT_FileAccess_CRT;
+    return new CFXCRT_FileAccess_CRT;
 }
 void FXCRT_GetFileModeString(FX_DWORD dwModes, CFX_ByteString &bsMode)
 {
diff --git a/core/src/fxcrt/fxcrt_posix.cpp b/core/src/fxcrt/fxcrt_posix.cpp
index 98f9a71..2982435 100644
--- a/core/src/fxcrt/fxcrt_posix.cpp
+++ b/core/src/fxcrt/fxcrt_posix.cpp
@@ -9,7 +9,7 @@
 #if _FXM_PLATFORM_ == _FXM_PLATFORM_LINUX_ || _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ || _FXM_PLATFORM_ == _FXM_PLATFORM_ANDROID_
 IFXCRT_FileAccess* FXCRT_FileAccess_Create()
 {
-    return FX_NEW CFXCRT_FileAccess_Posix;
+    return new CFXCRT_FileAccess_Posix;
 }
 void FXCRT_Posix_GetFileMode(FX_DWORD dwModes, FX_INT32 &nFlags, FX_INT32 &nMasks)
 {
diff --git a/core/src/fxcrt/fxcrt_windows.cpp b/core/src/fxcrt/fxcrt_windows.cpp
index 6b0f0f2..05ed619 100644
--- a/core/src/fxcrt/fxcrt_windows.cpp
+++ b/core/src/fxcrt/fxcrt_windows.cpp
@@ -25,7 +25,7 @@
 }
 IFXCRT_FileAccess* FXCRT_FileAccess_Create()
 {
-    return FX_NEW CFXCRT_FileAccess_Win64;
+    return new CFXCRT_FileAccess_Win64;
 }
 void FXCRT_Windows_GetFileMode(FX_DWORD dwMode, FX_DWORD &dwAccess, FX_DWORD &dwShare, FX_DWORD &dwCreation)
 {
diff --git a/core/src/fxge/agg/agg23/fx_agg_driver.cpp b/core/src/fxge/agg/agg23/fx_agg_driver.cpp
index 5944332..08f76bf 100644
--- a/core/src/fxge/agg/agg23/fx_agg_driver.cpp
+++ b/core/src/fxge/agg/agg23/fx_agg_driver.cpp
@@ -187,7 +187,7 @@
 }
 IFX_RenderDeviceDriver* IFX_RenderDeviceDriver::CreateFxgeDriver(CFX_DIBitmap* pBitmap, FX_BOOL bRgbByteOrder, CFX_DIBitmap* pOriDevice, FX_BOOL bGroupKnockout)
 {
-    return FX_NEW CFX_AggDeviceDriver(pBitmap, 0, bRgbByteOrder, pOriDevice, bGroupKnockout);
+    return new CFX_AggDeviceDriver(pBitmap, 0, bRgbByteOrder, pOriDevice, bGroupKnockout);
 }
 CFX_AggDeviceDriver::CFX_AggDeviceDriver(CFX_DIBitmap* pBitmap, int dither_bits, FX_BOOL bRgbByteOrder, CFX_DIBitmap* pOriDevice, FX_BOOL bGroupKnockout)
 {
@@ -267,10 +267,7 @@
 {
     void* pClip = NULL;
     if (m_pClipRgn) {
-        pClip = FX_NEW CFX_ClipRgn(*m_pClipRgn);
-        if (!pClip) {
-            return;
-        }
+        pClip = new CFX_ClipRgn(*m_pClipRgn);
     }
     m_StateStack.Add(pClip);
 }
@@ -290,7 +287,7 @@
     }
     if (bKeepSaved) {
         if (pSavedClip) {
-            m_pClipRgn = FX_NEW CFX_ClipRgn(*pSavedClip);
+            m_pClipRgn = new CFX_ClipRgn(*pSavedClip);
         }
     } else {
         m_StateStack.RemoveAt(m_StateStack.GetSize() - 1);
@@ -325,10 +322,7 @@
 {
     m_FillFlags = fill_mode;
     if (m_pClipRgn == NULL) {
-        m_pClipRgn = FX_NEW CFX_ClipRgn(GetDeviceCaps(FXDC_PIXEL_WIDTH), GetDeviceCaps(FXDC_PIXEL_HEIGHT));
-        if (!m_pClipRgn) {
-            return FALSE;
-        }
+        m_pClipRgn = new CFX_ClipRgn(GetDeviceCaps(FXDC_PIXEL_WIDTH), GetDeviceCaps(FXDC_PIXEL_HEIGHT));
     }
     if (pPathData->GetPointCount() == 5 || pPathData->GetPointCount() == 4) {
         CFX_FloatRect rectf;
@@ -355,10 +349,7 @@
                                                )
 {
     if (m_pClipRgn == NULL) {
-        m_pClipRgn = FX_NEW CFX_ClipRgn(GetDeviceCaps(FXDC_PIXEL_WIDTH), GetDeviceCaps(FXDC_PIXEL_HEIGHT));
-        if (!m_pClipRgn) {
-            return FALSE;
-        }
+        m_pClipRgn = new CFX_ClipRgn(GetDeviceCaps(FXDC_PIXEL_WIDTH), GetDeviceCaps(FXDC_PIXEL_HEIGHT));
     }
     CAgg_PathData path_data;
     path_data.BuildPath(pPathData, NULL);
@@ -1565,10 +1556,7 @@
     if (m_pBitmap->GetBuffer() == NULL) {
         return TRUE;
     }
-    CFX_ImageRenderer* pRenderer = FX_NEW CFX_ImageRenderer;
-    if (!pRenderer) {
-        return FALSE;
-    }
+    CFX_ImageRenderer* pRenderer = new CFX_ImageRenderer;
     pRenderer->Start(m_pBitmap, m_pClipRgn, pSource, bitmap_alpha, argb, pMatrix, render_flags, m_bRgbByteOrder, alpha_flag, pIccTransform);
     handle = pRenderer;
     return TRUE;
@@ -1597,29 +1585,20 @@
         return FALSE;
     }
     SetBitmap(pBitmap);
-    IFX_RenderDeviceDriver* pDriver = FX_NEW CFX_AggDeviceDriver(pBitmap, dither_bits, bRgbByteOrder, pOriDevice, bGroupKnockout);
-    if (!pDriver) {
-        return FALSE;
-    }
+    IFX_RenderDeviceDriver* pDriver = new CFX_AggDeviceDriver(pBitmap, dither_bits, bRgbByteOrder, pOriDevice, bGroupKnockout);
     SetDeviceDriver(pDriver);
     return TRUE;
 }
 FX_BOOL CFX_FxgeDevice::Create(int width, int height, FXDIB_Format format, int dither_bits, CFX_DIBitmap* pOriDevice)
 {
     m_bOwnedBitmap = TRUE;
-    CFX_DIBitmap* pBitmap = FX_NEW CFX_DIBitmap;
-    if (!pBitmap) {
-        return FALSE;
-    }
+    CFX_DIBitmap* pBitmap = new CFX_DIBitmap;
     if (!pBitmap->Create(width, height, format)) {
         delete pBitmap;
         return FALSE;
     }
     SetBitmap(pBitmap);
-    IFX_RenderDeviceDriver* pDriver = FX_NEW CFX_AggDeviceDriver(pBitmap, dither_bits, FALSE, pOriDevice, FALSE);
-    if (!pDriver) {
-        return FALSE;
-    }
+    IFX_RenderDeviceDriver* pDriver = new CFX_AggDeviceDriver(pBitmap, dither_bits, FALSE, pOriDevice, FALSE);
     SetDeviceDriver(pDriver);
     return TRUE;
 }
diff --git a/core/src/fxge/android/fpf_skiafontmgr.cpp b/core/src/fxge/android/fpf_skiafontmgr.cpp
index a9bef8a..fc012ea 100644
--- a/core/src/fxge/android/fpf_skiafontmgr.cpp
+++ b/core/src/fxge/android/fpf_skiafontmgr.cpp
@@ -352,16 +352,12 @@
     }
     if (nItem > -1) {
         CFPF_SkiaFontDescriptor *pFontDes = (CFPF_SkiaFontDescriptor*)m_FontFaces.ElementAt(nItem);
-        CFPF_SkiaFont *pFont = FX_NEW CFPF_SkiaFont;
-        if (pFont) {
-            if (pFont->InitFont(this, pFontDes, bsFamilyname, dwStyle, uCharset)) {
-                m_FamilyFonts.SetAt((void*)(FX_UINTPTR)dwHash, (void*)pFont);
-                return pFont->Retain();
-            }
-            pFont->Release();
-            pFont = NULL;
+        CFPF_SkiaFont *pFont = new CFPF_SkiaFont;
+        if (pFont->InitFont(this, pFontDes, bsFamilyname, dwStyle, uCharset)) {
+            m_FamilyFonts.SetAt((void*)(FX_UINTPTR)dwHash, (void*)pFont);
+            return pFont->Retain();
         }
-        return pFont;
+        pFont->Release();
     }
     return NULL;
 }
@@ -464,10 +460,7 @@
 {
     FXFT_Face face = GetFontFace(file);
     if (face) {
-        CFPF_SkiaPathFont *pFontDesc = FX_NEW CFPF_SkiaPathFont;
-        if (!pFontDesc) {
-            return;
-        }
+        CFPF_SkiaPathFont *pFontDesc = new CFPF_SkiaPathFont;
         pFontDesc->SetPath(file.GetCStr());
         ReportFace(face, pFontDesc);
         m_FontFaces.Add(pFontDesc);
diff --git a/core/src/fxge/android/fpf_skiamodule.cpp b/core/src/fxge/android/fpf_skiamodule.cpp
index 94e6888..6b5987d 100644
--- a/core/src/fxge/android/fpf_skiamodule.cpp
+++ b/core/src/fxge/android/fpf_skiamodule.cpp
@@ -12,7 +12,7 @@
 IFPF_DeviceModule* FPF_GetDeviceModule()
 {
     if (!gs_pPFModule) {
-        gs_pPFModule = FX_NEW CFPF_SkiaDeviceModule;
+        gs_pPFModule = new CFPF_SkiaDeviceModule;
     }
     return gs_pPFModule;
 }
@@ -32,10 +32,7 @@
 IFPF_FontMgr* CFPF_SkiaDeviceModule::GetFontMgr()
 {
     if (!m_pFontMgr) {
-        m_pFontMgr = FX_NEW CFPF_SkiaFontMgr;
-        if (!m_pFontMgr) {
-            return NULL;
-        }
+        m_pFontMgr = new CFPF_SkiaFontMgr;
         if (!m_pFontMgr->InitFTLibrary()) {
             delete m_pFontMgr;
             return NULL;
diff --git a/core/src/fxge/android/fx_android_imp.cpp b/core/src/fxge/android/fx_android_imp.cpp
index 528877e..a1631ab 100644
--- a/core/src/fxge/android/fx_android_imp.cpp
+++ b/core/src/fxge/android/fx_android_imp.cpp
@@ -14,10 +14,7 @@
     }
     IFPF_FontMgr *pFontMgr = pDeviceModule->GetFontMgr();
     if (pFontMgr) {
-        CFX_AndroidFontInfo *pFontInfo = FX_NEW CFX_AndroidFontInfo;
-        if (!pFontInfo) {
-            return;
-        }
+        CFX_AndroidFontInfo *pFontInfo = new CFX_AndroidFontInfo;
         pFontInfo->Init(pFontMgr);
         m_pFontMgr->SetSystemFontInfo(pFontInfo);
     }
diff --git a/core/src/reflow/autoreflow.cpp b/core/src/reflow/autoreflow.cpp
index 8c37960..a101755 100644
--- a/core/src/reflow/autoreflow.cpp
+++ b/core/src/reflow/autoreflow.cpp
@@ -100,7 +100,7 @@
 }
 IPDF_LayoutProvider* IPDF_LayoutProvider::Create_LayoutProvider_AutoReflow(CPDF_PageObjects* pPage, FX_BOOL bReadOrder)
 {
-    return FX_NEW CPDF_AutoReflowLayoutProvider(pPage, bReadOrder);
+    return new CPDF_AutoReflowLayoutProvider(pPage, bReadOrder);
 }
 CPDF_AutoReflowElement::CPDF_AutoReflowElement(LayoutType layoutType , CPDF_AutoReflowElement* pParent)
 {
@@ -251,8 +251,7 @@
         } else {
             pNextCell = NULL;
         }
-        pCurrElm = NULL;
-        pCurrElm = FX_NEW CPDF_AutoReflowElement(LayoutParagraph, pParent);
+        pCurrElm = new CPDF_AutoReflowElement(LayoutParagraph, pParent);
         if(pCurrElm->GetType() == LayoutParagraph && plastCell) {
             int SpaceBefore = 0;
             if(pCell->m_CellWritingMode != plastCell->m_CellWritingMode ) {
@@ -561,7 +560,7 @@
         pPerObj = pObj;
         if(bNewLine) {
             int c = pCell ? pCell->m_ObjList.GetCount() : 0;
-            pCell = FX_NEW CRF_CELL;
+            pCell = new CRF_CELL;
             pCell->m_CellWritingMode = m_WritingMode;
             pCell->m_BBox = ObjBBox;
             if(pObj->m_Type == PDFPAGE_TEXT) {
@@ -719,10 +718,7 @@
 LayoutStatus CPDF_AutoReflowLayoutProvider::StartLoad(IFX_Pause* pPause)
 {
     m_pPause = pPause;
-    m_pRoot = FX_NEW CPDF_AutoReflowElement(LayoutDocument);
-    if(!m_pRoot) {
-        return LayoutError;
-    }
+    m_pRoot = new CPDF_AutoReflowElement(LayoutDocument);
     m_Step = 0;
     return Continue();
 }
diff --git a/core/src/reflow/layoutprocessor_reflow.cpp b/core/src/reflow/layoutprocessor_reflow.cpp
index d2fa7e9..218d301 100644
--- a/core/src/reflow/layoutprocessor_reflow.cpp
+++ b/core/src/reflow/layoutprocessor_reflow.cpp
@@ -12,10 +12,7 @@
     if(pReflowedPage == NULL || fWidth <= 20) {
         return NULL;
     }
-    CPDF_LayoutProcessor_Reflow* pReflowEngine = FX_NEW CPDF_LayoutProcessor_Reflow();
-    if (NULL == pReflowEngine) {
-        return NULL;
-    }
+    CPDF_LayoutProcessor_Reflow* pReflowEngine = new CPDF_LayoutProcessor_Reflow();
     pReflowEngine->Init(TopIndent, fWidth, fHeight, (CPDF_ReflowedPage*)pReflowedPage, flags, lineSpace);
     return pReflowEngine;
 }
@@ -29,8 +26,8 @@
     m_fCurrLineHeight = 0;
     m_bIllustration = FALSE;
     m_pPreObj = NULL;
-    m_pCurrLine = FX_NEW CRF_DataPtrArray(50);
-    m_pTempLine = FX_NEW CRF_DataPtrArray(50);
+    m_pCurrLine = new CRF_DataPtrArray(50);
+    m_pTempLine = new CRF_DataPtrArray(50);
     m_StartIndent = 0;
     m_PausePosition = 0;
 }
@@ -557,10 +554,7 @@
         }
         switch(layoutType) {
             case LayoutTable: {
-                    CRF_Table* pTable = FX_NEW CRF_Table;
-                    if (NULL == pTable) {
-                        break;
-                    }
+                    CRF_Table* pTable = new CRF_Table;
                     m_TableArray.Add(pTable);
                     pTable->m_ReflowPageHeight = m_pReflowedPage->m_PageHeight;
                     pTable->m_TableWidth = GetElmWidth(pElement);
@@ -771,10 +765,7 @@
         if(!(m_flags & RF_PARSER_IMAGE)) {
             return;
         }
-        CPDF_PageObjects* pObjs = FX_NEW CPDF_PageObjects(FALSE);
-        if (NULL == pObjs) {
-            return;
-        }
+        CPDF_PageObjects* pObjs = new CPDF_PageObjects(FALSE);
         FX_POSITION pos = pObjs->GetLastObjectPosition();
         pos = pObjs->InsertObject(pos, pObj);
         CFX_AffineMatrix matrix;
diff --git a/core/src/reflow/layoutprovider_taggedpdf.cpp b/core/src/reflow/layoutprovider_taggedpdf.cpp
index c40c1cd..4a5a22b 100644
--- a/core/src/reflow/layoutprovider_taggedpdf.cpp
+++ b/core/src/reflow/layoutprovider_taggedpdf.cpp
@@ -636,10 +636,7 @@
     if(pPage == NULL) {
         return NULL;
     }
-    CPDF_LayoutProvider_TaggedPDF* pProvider = FX_NEW CPDF_LayoutProvider_TaggedPDF;
-    if (!pProvider) {
-        return NULL;
-    }
+    CPDF_LayoutProvider_TaggedPDF* pProvider = new CPDF_LayoutProvider_TaggedPDF;
     pProvider->Init(pPage);
     return pProvider;
 }
@@ -672,11 +669,7 @@
         m_Status = LayoutError;
         return;
     }
-    CPDF_LayoutElement* pElement = FX_NEW CPDF_LayoutElement;
-    if (!pElement) {
-        m_Status = LayoutError;
-        return;
-    }
+    CPDF_LayoutElement* pElement = new CPDF_LayoutElement;
     pElement->m_pParentElement = pParent;
     pElement->m_pTaggedElement = pTaggedElement;
     pParent->m_ChildArray.Add(pElement);
@@ -729,11 +722,7 @@
         m_Status = LayoutError;
         return LayoutError;
     }
-    m_pRoot = FX_NEW CPDF_LayoutElement;
-    if (!m_pRoot) {
-        m_Status = LayoutError;
-        return LayoutError;
-    }
+    m_pRoot = new CPDF_LayoutElement;
     for(int i = 0; i < count; i++) {
         CPDF_StructElement* pElement = m_pPageTree->GetTopElement(i);
         if(pElement) {
diff --git a/core/src/reflow/reflowedpage.cpp b/core/src/reflow/reflowedpage.cpp
index 11baef8..ba2667f 100644
--- a/core/src/reflow/reflowedpage.cpp
+++ b/core/src/reflow/reflowedpage.cpp
@@ -36,11 +36,11 @@
         m_pMemoryPool = pMemoryPool;
         m_bCreateMemoryPool = FALSE;
     } else {
-        m_pMemoryPool = FX_NEW CFX_GrowOnlyPool;
+        m_pMemoryPool = new CFX_GrowOnlyPool;
         m_bCreateMemoryPool = TRUE;
     }
-    m_pCharState = FX_NEW CRF_CharStateArray(10);
-    m_pReflowed = FX_NEW CRF_DataPtrArray(500);
+    m_pCharState = new CRF_CharStateArray(10);
+    m_pReflowed = new CRF_DataPtrArray(500);
     m_pPageInfos = NULL;
 }
 CPDF_ReflowedPage::~CPDF_ReflowedPage()
@@ -79,7 +79,7 @@
         return FALSE;
     }
     if (NULL == m_pPageInfos) {
-        m_pPageInfos = FX_NEW CFX_MapPtrToPtr();
+        m_pPageInfos = new CFX_MapPtrToPtr();
     } else {
         return TRUE;
     }
@@ -100,10 +100,7 @@
     if (NULL == m_pPageInfos) {
         return;
     }
-    CRF_PageInfo* pPageInfo = FX_NEW CRF_PageInfo(pObj, pParent);
-    if (NULL == pPageInfo) {
-        return;
-    }
+    CRF_PageInfo* pPageInfo = new CRF_PageInfo(pObj, pParent);
     m_pPageInfos->SetAt(pObj, pPageInfo);
     if (PDFPAGE_FORM != pObj->m_Type) {
         return;
@@ -593,11 +590,9 @@
     m_pReflowPage = (CPDF_ReflowedPage*)pReflowPage;
     m_pFXDevice = pDevice;
     if(NULL == m_pDisplayMatrix) {
-        m_pDisplayMatrix = FX_NEW CFX_AffineMatrix;
+        m_pDisplayMatrix = new CFX_AffineMatrix;
     }
-    if (m_pDisplayMatrix) {
-        m_pDisplayMatrix->Copy(*pMatrix);
-    }
+    m_pDisplayMatrix->Copy(*pMatrix);
     m_Status = ToBeContinued;
     Display(pPause);
 }
diff --git a/core/src/reflow/reflowedtextpage.cpp b/core/src/reflow/reflowedtextpage.cpp
index a5ad0be..0844f78 100644
--- a/core/src/reflow/reflowedtextpage.cpp
+++ b/core/src/reflow/reflowedtextpage.cpp
@@ -4,10 +4,13 @@
  
 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
 
+#include <algorithm>
+
 #include "reflowedtextpage.h"
+
 IPDF_TextPage*	IPDF_TextPage::CreateReflowTextPage(IPDF_ReflowedPage* pRefPage)
 {
-    return FX_NEW CRF_TextPage(pRefPage);
+    return new CRF_TextPage(pRefPage);
 }
 CRF_TextPage::CRF_TextPage(IPDF_ReflowedPage* pRefPage)
 {
@@ -32,24 +35,14 @@
         return FALSE;
     }
     int count = m_pRefPage->m_pReflowed->GetSize();
-    if(count < 500) {
-        m_pDataList = FX_NEW CRF_CharDataPtrArray(count);
-    } else {
-        m_pDataList = FX_NEW CRF_CharDataPtrArray(500);
-    }
-    if (NULL == m_pDataList) {
-        return FALSE;
-    }
+    m_pDataList = new CRF_CharDataPtrArray(std::min(count, 500));
     for(int i = 0; i < count; i++) {
         CRF_Data* pData = (*(m_pRefPage->m_pReflowed))[i];
         if(pData->GetType() == CRF_Data::Text) {
             m_pDataList->Add((CRF_CharData*)pData);
         }
     }
-    m_CountBSArray = FX_NEW CFX_CountBSINT32Array(20);
-    if(NULL == m_CountBSArray) {
-        return FALSE;
-    }
+    m_CountBSArray = new CFX_CountBSINT32Array(20);
     return TRUE;
 }
 FX_BOOL	CRF_TextPage::IsParsered() const
diff --git a/core/src/reflow/reflowengine.cpp b/core/src/reflow/reflowengine.cpp
index 11007c9..7f766ca 100644
--- a/core/src/reflow/reflowengine.cpp
+++ b/core/src/reflow/reflowengine.cpp
@@ -8,8 +8,7 @@
 #include "reflowedpage.h"
 IPDF_ReflowedPage* IPDF_ReflowedPage::Create()
 {
-    CPDF_ReflowedPage* pRefPage = FX_NEW CPDF_ReflowedPage(NULL);
-    return pRefPage;
+    return new CPDF_ReflowedPage(NULL);
 }
 IPDF_ReflowedPage* Create_ReflowPage()
 {
@@ -21,10 +20,7 @@
 }
 IPDF_ProgressiveReflowPageParser* IPDF_ProgressiveReflowPageParser::Create()
 {
-    CPDF_ProgressiveReflowPageParser* pParser = FX_NEW CPDF_ProgressiveReflowPageParser;
-    if (NULL == pParser) {
-        return NULL;
-    }
+    CPDF_ProgressiveReflowPageParser* pParser = new CPDF_ProgressiveReflowPageParser;
     pParser->Init();
     return pParser;
 }
@@ -34,5 +30,5 @@
 }
 IPDF_ProgressiveReflowPageRender* IPDF_ProgressiveReflowPageRender::Create()
 {
-    return FX_NEW CPDF_ProgressiveReflowPageRender;
+    return new CPDF_ProgressiveReflowPageRender;
 }
diff --git a/fpdfsdk/src/fpdf_flatten.cpp b/fpdfsdk/src/fpdf_flatten.cpp
index 26ea294..51e208f 100644
--- a/fpdfsdk/src/fpdf_flatten.cpp
+++ b/fpdfsdk/src/fpdf_flatten.cpp
@@ -215,7 +215,7 @@
 		//Create a new contents dictionary
 		if (!key.IsEmpty())
 		{
-			CPDF_Stream* pNewContents = new CPDF_Stream(NULL, 0, FX_NEW CPDF_Dictionary);
+			CPDF_Stream* pNewContents = new CPDF_Stream(NULL, 0, new CPDF_Dictionary);
 			pPage->SetAtReference("Contents", pDocument, pDocument->AddIndirectObject(pNewContents));
 
 			CFX_ByteString sStream;
@@ -261,10 +261,10 @@
 	
 	if (!key.IsEmpty())
 	{
-		CPDF_Stream* pNewContents = new CPDF_Stream(NULL, 0, FX_NEW CPDF_Dictionary);
+		CPDF_Stream* pNewContents = new CPDF_Stream(NULL, 0, new CPDF_Dictionary);
 		dwObjNum = pDocument->AddIndirectObject(pNewContents);
 		pContentsArray->AddReference(pDocument, dwObjNum);
-		
+
 		CFX_ByteString sStream;
 		sStream.Format("q 1 0 0 1 0 0 cm /%s Do Q", key.c_str());
 		pNewContents->SetData((FX_LPCBYTE)sStream, sStream.GetLength(), FALSE, FALSE);
@@ -399,10 +399,10 @@
 	if (!pRes)
 	{
 		pRes = new CPDF_Dictionary;
-		pPageDict->SetAt("Resources", pRes);
+		pPageDict->SetAt("Resources", pRes );
 	}
 
-	CPDF_Stream* pNewXObject = new CPDF_Stream(NULL, 0, FX_NEW CPDF_Dictionary);
+	CPDF_Stream* pNewXObject = new CPDF_Stream(NULL, 0, new CPDF_Dictionary);
 	FX_DWORD dwObjNum = pDocument->AddIndirectObject(pNewXObject);
 	CPDF_Dictionary* pPageXObject = pRes->GetDict("XObject");
 	if (!pPageXObject)