Merge to XFA: Remove FX_NEW_VECTOR() macros.
authorTom Sepez <tsepez@chromium.org>
Fri, 15 May 2015 21:01:28 +0000 (14:01 -0700)
committerTom Sepez <tsepez@chromium.org>
Fri, 15 May 2015 21:01:28 +0000 (14:01 -0700)
Original Review URL: https://codereview.chromium.org/1135273004

R=thestig@chromium.org
TBR=thestig@chromium.org

Review URL: https://codereview.chromium.org/1134003007

core/include/fxcrt/fx_memory.h
core/src/fpdfapi/fpdf_font/fpdf_font.cpp
core/src/fpdfapi/fpdf_page/fpdf_page_graph_state.cpp
core/src/fpdfapi/fpdf_page/fpdf_page_parser.cpp

index 4d56736..e6685ef 100644 (file)
@@ -25,8 +25,6 @@ void  FXMEM_DefaultFree(void* pointer, int flags);
 }
 
 #define FX_NEW new
-#define FX_NEW_VECTOR(Pointer, Class, Count) (Pointer = FX_NEW Class[Count])
-#define FX_DELETE_VECTOR(Pointer, Class, Count) delete[] Pointer
 
 class CFX_DestructObject 
 {
index 66d7d4f..80dd1df 100644 (file)
@@ -786,7 +786,7 @@ void CPDF_Font::LoadPDFEncoding(CPDF_Object* pEncoding, int& iBaseEncoding, CFX_
     if (pDiffs == NULL) {
         return;
     }
-    FX_NEW_VECTOR(pCharNames, CFX_ByteString, 256);
+    pCharNames = new CFX_ByteString[256];
     FX_DWORD cur_code = 0;
     for (FX_DWORD i = 0; i < pDiffs->GetCount(); i ++) {
         CPDF_Object* pElement = pDiffs->GetElementValue(i);
@@ -828,9 +828,7 @@ CPDF_SimpleFont::CPDF_SimpleFont(int fonttype) : CPDF_Font(fonttype)
 }
 CPDF_SimpleFont::~CPDF_SimpleFont()
 {
-    if (m_pCharNames) {
-        FX_DELETE_VECTOR(m_pCharNames, CFX_ByteString, 256);
-    }
+    delete[] m_pCharNames;
 }
 int CPDF_SimpleFont::GlyphFromCharCode(FX_DWORD charcode, FX_BOOL *pVertGlyph)
 {
@@ -971,10 +969,8 @@ FX_BOOL CPDF_SimpleFont::LoadCommon()
     CPDF_Object* pEncoding = m_pFontDict->GetElementValue(FX_BSTRC("Encoding"));
     LoadPDFEncoding(pEncoding, m_BaseEncoding, m_pCharNames, m_pFontFile != NULL, m_Font.IsTTFont());
     LoadGlyphMap();
-    if (m_pCharNames) {
-        FX_DELETE_VECTOR(m_pCharNames, CFX_ByteString, 256);
-        m_pCharNames = NULL;
-    }
+    delete[] m_pCharNames;
+    m_pCharNames = NULL;
     if (m_Font.m_Face == NULL) {
         return TRUE;
     }
index e098f66..2bf3b1d 100644 (file)
@@ -33,9 +33,7 @@ CPDF_ClipPathData::CPDF_ClipPathData()
 CPDF_ClipPathData::~CPDF_ClipPathData()
 {
     int i;
-    if (m_pPathList) {
-        FX_DELETE_VECTOR(m_pPathList, CPDF_Path, m_PathCount);
-    }
+    delete[] m_pPathList;
     if (m_pTypeList) {
         FX_Free(m_pTypeList);
     }
@@ -58,7 +56,7 @@ CPDF_ClipPathData::CPDF_ClipPathData(const CPDF_ClipPathData& src)
         if (alloc_size % 8) {
             alloc_size += 8 - (alloc_size % 8);
         }
-        FX_NEW_VECTOR(m_pPathList, CPDF_Path, alloc_size);
+        m_pPathList = new CPDF_Path[alloc_size];
         for (int i = 0; i < m_PathCount; i ++) {
             m_pPathList[i] = src.m_pPathList[i];
         }
@@ -89,7 +87,7 @@ void CPDF_ClipPathData::SetCount(int path_count, int text_count)
     if (path_count) {
         m_PathCount = path_count;
         int alloc_size = (path_count + 7) / 8 * 8;
-        FX_NEW_VECTOR(m_pPathList, CPDF_Path, alloc_size);
+        m_pPathList = new CPDF_Path[alloc_size];
         m_pTypeList = FX_Alloc(FX_BYTE, alloc_size);
     }
     if (text_count) {
@@ -152,14 +150,11 @@ void CPDF_ClipPath::AppendPath(CPDF_Path path, int type, FX_BOOL bAutoMerge)
         }
     }
     if (pData->m_PathCount % 8 == 0) {
-        CPDF_Path* pNewPath;
-        FX_NEW_VECTOR(pNewPath, CPDF_Path, pData->m_PathCount + 8);
+        CPDF_Path* pNewPath = new CPDF_Path[pData->m_PathCount + 8];
         for (int i = 0; i < pData->m_PathCount; i ++) {
             pNewPath[i] = pData->m_pPathList[i];
         }
-        if (pData->m_pPathList) {
-            FX_DELETE_VECTOR(pData->m_pPathList, CPDF_Path, pData->m_PathCount);
-        }
+        delete[] pData->m_pPathList;
         FX_BYTE* pNewType = FX_Alloc(FX_BYTE, pData->m_PathCount + 8);
         FXSYS_memcpy32(pNewType, pData->m_pTypeList, pData->m_PathCount);
         if (pData->m_pTypeList) {
index b306c66..b3e3cd6 100644 (file)
@@ -1348,8 +1348,7 @@ void CPDF_StreamContentParser::Handle_ShowText_Positioning()
         };
         return;
     }
-    CFX_ByteString* pStrs;
-    FX_NEW_VECTOR(pStrs, CFX_ByteString, nsegs);
+    CFX_ByteString* pStrs = new CFX_ByteString[nsegs];
     FX_FLOAT* pKerning = FX_Alloc(FX_FLOAT, nsegs);
     int iSegment = 0;
     FX_FLOAT fInitKerning = 0;
@@ -1372,7 +1371,7 @@ void CPDF_StreamContentParser::Handle_ShowText_Positioning()
         }
     }
     AddTextObject(pStrs, fInitKerning, pKerning, iSegment);
-    FX_DELETE_VECTOR(pStrs, CFX_ByteString, nsegs);
+    delete[] pStrs;
     FX_Free(pKerning);
 }
 void CPDF_StreamContentParser::Handle_SetTextLeading()