From 1871821653de9f4b1706d726f4d318cf739e55af Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Thu, 17 Dec 2015 10:37:41 -0800 Subject: Remove FDE_Alloc in favor of FX_Alloc. R=thestig@chromium.org Review URL: https://codereview.chromium.org/1521163002 . --- xfa/src/fgas/src/crt/fx_memory.cpp | 3 --- xfa/src/fgas/src/crt/fx_stream.cpp | 4 ++-- xfa/src/fgas/src/crt/fx_utils.cpp | 12 +++++------- xfa/src/fgas/src/font/fx_gdifont.cpp | 23 ++++++++--------------- xfa/src/fgas/src/font/fx_stdfontmgr.cpp | 13 ++++--------- xfa/src/fgas/src/xml/fx_sax_imp.cpp | 7 ++----- 6 files changed, 21 insertions(+), 41 deletions(-) (limited to 'xfa/src/fgas') diff --git a/xfa/src/fgas/src/crt/fx_memory.cpp b/xfa/src/fgas/src/crt/fx_memory.cpp index f3d0f10aa3..ae387b2ee0 100644 --- a/xfa/src/fgas/src/crt/fx_memory.cpp +++ b/xfa/src/fgas/src/crt/fx_memory.cpp @@ -45,9 +45,6 @@ FX_LPSTATICSTORECHUNK CFX_StaticStore::AllocChunk(size_t size) { FXSYS_assert(size != 0); FX_LPSTATICSTORECHUNK pChunk = (FX_LPSTATICSTORECHUNK)FX_Alloc( uint8_t, sizeof(FX_STATICSTORECHUNK) + size); - if (pChunk == NULL) { - return NULL; - } pChunk->iChunkSize = size; pChunk->iFreeSize = size; pChunk->pNextChunk = NULL; diff --git a/xfa/src/fgas/src/crt/fx_stream.cpp b/xfa/src/fgas/src/crt/fx_stream.cpp index 11ce71f9a3..57bf13fa29 100644 --- a/xfa/src/fgas/src/crt/fx_stream.cpp +++ b/xfa/src/fgas/src/crt/fx_stream.cpp @@ -791,10 +791,10 @@ int32_t CFX_TextStream::ReadString(FX_WCHAR* pStr, iBytes = FX_MIN(iBytes, m_pStreamImp->GetLength() - pos); if (iBytes > 0) { if (m_pBuf == NULL) { - m_pBuf = (uint8_t*)FX_Alloc(uint8_t, iBytes); + m_pBuf = FX_Alloc(uint8_t, iBytes); m_iBufSize = iBytes; } else if (iBytes > m_iBufSize) { - m_pBuf = (uint8_t*)FX_Realloc(uint8_t, m_pBuf, iBytes); + m_pBuf = FX_Realloc(uint8_t, m_pBuf, iBytes); m_iBufSize = iBytes; } m_pStreamImp->Lock(); diff --git a/xfa/src/fgas/src/crt/fx_utils.cpp b/xfa/src/fgas/src/crt/fx_utils.cpp index 8389452c81..4d27e5bf19 100644 --- a/xfa/src/fgas/src/crt/fx_utils.cpp +++ b/xfa/src/fgas/src/crt/fx_utils.cpp @@ -49,13 +49,12 @@ uint8_t* CFX_BaseArray::AddSpaceTo(int32_t index) { int32_t iGrowSize = m_pData->iGrowSize; iTotalCount = (index / iGrowSize + 1) * iGrowSize; int32_t iNewSize = iTotalCount * iBlockSize; - if (pBuffer == NULL) { + if (!pBuffer) { pBuffer = FX_Alloc(uint8_t, iNewSize); } else { pBuffer = FX_Realloc(uint8_t, pBuffer, iNewSize); } } - FXSYS_assert(pBuffer != NULL); int32_t& iBlockCount = m_pData->iBlockCount; if (index >= iBlockCount) { iBlockCount = index + 1; @@ -161,7 +160,7 @@ uint8_t* CFX_BaseMassArrayImp::AddSpaceTo(int32_t index) { pChunk = (uint8_t*)m_pData->GetAt(index / m_iChunkSize); break; } else { - pChunk = (uint8_t*)FX_Alloc(uint8_t, iMemSize); + pChunk = FX_Alloc(uint8_t, iMemSize); if (m_iChunkCount < m_pData->GetSize()) { m_pData->SetAt(m_iChunkCount, pChunk); } else { @@ -354,10 +353,9 @@ uint8_t* CFX_BaseDiscreteArray::AddSpaceTo(int32_t index) { if (iChunk < iChunkCount) { pChunk = (uint8_t*)pData->ChunkBuffer.GetAt(iChunk); } - if (pChunk == NULL) { - int32_t iMemSize = iChunkSize * pData->iBlockSize; - pChunk = (uint8_t*)FX_Alloc(uint8_t, iMemSize); - FXSYS_memset(pChunk, 0, iMemSize); + if (!pChunk) { + pChunk = FX_Alloc2D(uint8_t, iChunkSize, pData->iBlockSize); + FXSYS_memset(pChunk, 0, iChunkSize * pData->iBlockSize); pData->ChunkBuffer.SetAtGrow(iChunk, pChunk); if (iChunkCount <= iChunk) { iChunkCount = iChunk + 1; diff --git a/xfa/src/fgas/src/font/fx_gdifont.cpp b/xfa/src/fgas/src/font/fx_gdifont.cpp index fe02a049ad..6840c5bddf 100644 --- a/xfa/src/fgas/src/font/fx_gdifont.cpp +++ b/xfa/src/fgas/src/font/fx_gdifont.cpp @@ -19,8 +19,8 @@ CFX_GdiFontCache::~CFX_GdiFontCache() { pGlyph = NULL; m_GlyphMap.GetNextAssoc(pos, (void*&)iGlyph, (void*&)pGlyph); if (pGlyph != NULL) { - FDE_Free(pGlyph->pOutline); - FDE_Free(pGlyph); + FX_Free(pGlyph->pOutline); + FX_Free(pGlyph); } } m_GlyphMap.RemoveAll(); @@ -29,7 +29,7 @@ void CFX_GdiFontCache::SetCachedGlyphOutline(FX_DWORD dwGlyph, const GLYPHMETRICS& gm, uint8_t* pOutline) { FXSYS_assert(pOutline != NULL); - FX_LPGDIGOCACHE pGlyph = (FX_LPGDIGOCACHE)FDE_Alloc(sizeof(FX_GDIGOCACHE)); + FX_LPGDIGOCACHE pGlyph = FX_Alloc(FX_GDIGOCACHE, 1); pGlyph->gm = gm; pGlyph->pOutline = pOutline; m_GlyphMap.SetAt((void*)dwGlyph, (void*)pGlyph); @@ -250,13 +250,10 @@ FX_BOOL CFX_GdiFont::LoadFont(IFX_Stream* pFontStream) { if (iLength < 1) { return FALSE; } - uint8_t* pBuf = (uint8_t*)FDE_Alloc(iLength); - if (pBuf == NULL) { - return FALSE; - } + uint8_t* pBuf = FX_Alloc(uint8_t, iLength); iLength = pFontStream->ReadData(pBuf, iLength); FX_BOOL bRet = LoadFont(pBuf, iLength); - FDE_Free(pBuf); + FX_Free(pBuf); return bRet; } FX_BOOL CFX_GdiFont::LoadFont(const LOGFONTW& lf) { @@ -275,11 +272,7 @@ int32_t CFX_GdiFont::GetFontFamilies(Gdiplus::FontCollection& fc) { if (iCount < 1) { return iCount; } - Gdiplus::FontFamily* pFontFamilies = - (Gdiplus::FontFamily*)FDE_Alloc(iCount * sizeof(Gdiplus::FontFamily)); - if (pFontFamilies == NULL) { - return -1; - } + Gdiplus::FontFamily* pFontFamilies = FX_Alloc(Gdiplus::FontFamily, iCount); int32_t iFind = 0; fc.GetFamilies(iCount, pFontFamilies, &iFind); for (int32_t i = 0; i < iCount; i++) { @@ -289,7 +282,7 @@ int32_t CFX_GdiFont::GetFontFamilies(Gdiplus::FontCollection& fc) { wsFamilyName.ReleaseBuffer(); m_FontFamilies.Add(wsFamilyName); } - FDE_Free(pFontFamilies); + FX_Free(pFontFamilies); return iCount; } void CFX_GdiFont::RetrieveFontStyles() { @@ -487,7 +480,7 @@ FX_DWORD CFX_GdiFont::GetGlyphDIBits(int32_t iGlyphIndex, if (dwGlyphSize == 0 || dwGlyphSize == GDI_ERROR) { return 0; } - pGlyphOutline = (uint8_t*)FX_Alloc(dwGlyphSize); + pGlyphOutline = FX_Alloc(uint8_t, dwGlyphSize); ::GetGlyphOutlineW(m_hDC, iGlyphIndex, uFormat, &gm, dwGlyphSize, pGlyphOutline, pMatrix); if (pCache == NULL) { diff --git a/xfa/src/fgas/src/font/fx_stdfontmgr.cpp b/xfa/src/fgas/src/font/fx_stdfontmgr.cpp index 885e7557c1..807213394b 100644 --- a/xfa/src/fgas/src/font/fx_stdfontmgr.cpp +++ b/xfa/src/fgas/src/font/fx_stdfontmgr.cpp @@ -465,9 +465,6 @@ static int32_t CALLBACK FX_GdiFontEnumProc(ENUMLOGFONTEX* lpelfe, return 1; } FX_LPFONTDESCRIPTOR pFont = FX_Alloc(FX_FONTDESCRIPTOR, 1); - if (NULL == pFont) { - return 0; - } FXSYS_memset(pFont, 0, sizeof(FX_FONTDESCRIPTOR)); pFont->uCharSet = lf.lfCharSet; pFont->dwFontStyles = FX_GetGdiFontStyles(lf); @@ -1265,12 +1262,10 @@ void CFX_FontMgrImp::ReportFace(FXFT_Face pFace, unsigned int error = FXFT_Load_Sfnt_Table(pFace, dwTag, 0, NULL, &nLength); if (0 == error && 0 != nLength) { pTable = FX_Alloc(uint8_t, nLength); - if (NULL != pTable) { - error = FXFT_Load_Sfnt_Table(pFace, dwTag, 0, pTable, NULL); - if (0 != error) { - FX_Free(pTable); - pTable = NULL; - } + error = FXFT_Load_Sfnt_Table(pFace, dwTag, 0, pTable, NULL); + if (0 != error) { + FX_Free(pTable); + pTable = NULL; } } GetNames(pTable, pFont->m_wsFamilyNames); diff --git a/xfa/src/fgas/src/xml/fx_sax_imp.cpp b/xfa/src/fgas/src/xml/fx_sax_imp.cpp index 6a4ad34b8c..6ffa206f35 100644 --- a/xfa/src/fgas/src/xml/fx_sax_imp.cpp +++ b/xfa/src/fgas/src/xml/fx_sax_imp.cpp @@ -33,9 +33,6 @@ FX_BOOL CFX_SAXFile::StartFile(IFX_FileRead* pFile, } m_dwBufSize = FX_MIN(dwLen, FX_SAXFILE_BUFSIZE); m_pBuf = FX_Alloc(uint8_t, m_dwBufSize); - if (!m_pBuf) { - return FALSE; - } if (!pFile->ReadBlock(m_pBuf, dwStart, m_dwBufSize)) { return FALSE; } @@ -77,8 +74,8 @@ CFX_SAXReader::CFX_SAXReader() m_iNameSize(256), m_dwParseMode(0), m_pCommentContext(nullptr) { - m_pszData = (uint8_t*)FX_Alloc(uint8_t, m_iDataSize); - m_pszName = (uint8_t*)FX_Alloc(uint8_t, m_iNameSize); + m_pszData = FX_Alloc(uint8_t, m_iDataSize); + m_pszName = FX_Alloc(uint8_t, m_iNameSize); } CFX_SAXReader::~CFX_SAXReader() { Reset(); -- cgit v1.2.3