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/fxfa/src/app/xfa_checksum.cpp | 1 - xfa/src/fxfa/src/app/xfa_ffdoc.cpp | 5 +---- xfa/src/fxfa/src/app/xfa_ffwidget.cpp | 14 +++++--------- xfa/src/fxfa/src/app/xfa_textlayout.cpp | 16 ++++++---------- xfa/src/fxfa/src/app/xfa_textlayout.h | 6 +----- xfa/src/fxfa/src/fm2js/xfa_fm2jscontext.cpp | 10 ++++------ 6 files changed, 17 insertions(+), 35 deletions(-) (limited to 'xfa/src/fxfa') diff --git a/xfa/src/fxfa/src/app/xfa_checksum.cpp b/xfa/src/fxfa/src/app/xfa_checksum.cpp index a70db6cba0..311c84111f 100644 --- a/xfa/src/fxfa/src/app/xfa_checksum.cpp +++ b/xfa/src/fxfa/src/app/xfa_checksum.cpp @@ -133,7 +133,6 @@ CXFA_ChecksumContext::~CXFA_ChecksumContext() { FX_BOOL CXFA_ChecksumContext::StartChecksum() { FinishChecksum(); m_pByteContext = FX_Alloc(uint8_t, 128); - FXSYS_assert(m_pByteContext != NULL); CRYPT_SHA1Start(m_pByteContext); m_bsChecksum.Empty(); m_pSAXReader = FX_SAXReader_Create(); diff --git a/xfa/src/fxfa/src/app/xfa_ffdoc.cpp b/xfa/src/fxfa/src/app/xfa_ffdoc.cpp index 0a4d592988..f53fe63f1a 100644 --- a/xfa/src/fxfa/src/app/xfa_ffdoc.cpp +++ b/xfa/src/fxfa/src/app/xfa_ffdoc.cpp @@ -76,10 +76,7 @@ FX_BOOL XFA_GetPDFContentsFromPDFXML(IFDE_XMLNode* pPDFElement, pChunkElement->GetTextData(wsPDFContent); iBufferSize = FX_Base64DecodeW(wsPDFContent, wsPDFContent.GetLength(), NULL); pByteBuffer = FX_Alloc(uint8_t, iBufferSize + 1); - if (!pByteBuffer) { - return FALSE; - } - pByteBuffer[iBufferSize] = '0'; + pByteBuffer[iBufferSize] = '0'; // FIXME: I bet this is wrong. FX_Base64DecodeW(wsPDFContent, wsPDFContent.GetLength(), pByteBuffer); return TRUE; } diff --git a/xfa/src/fxfa/src/app/xfa_ffwidget.cpp b/xfa/src/fxfa/src/app/xfa_ffwidget.cpp index a4015abe62..ed9bbb329b 100644 --- a/xfa/src/fxfa/src/app/xfa_ffwidget.cpp +++ b/xfa/src/fxfa/src/app/xfa_ffwidget.cpp @@ -841,7 +841,7 @@ static uint8_t* XFA_RemoveBase64Whitespace(const uint8_t* pStr, int32_t iLen) { if (iLen == 0) { iLen = FXSYS_strlen((FX_CHAR*)pStr); } - pCP = (uint8_t*)FDE_Alloc(iLen + 1); + pCP = FX_Alloc(uint8_t, iLen + 1); for (; i < iLen; i++) { if ((pStr[i] & 128) == 0) { if (g_inv_base64[pStr[i]] != 0xFF || pStr[i] == '=') { @@ -894,7 +894,7 @@ static int32_t XFA_Base64Decode(const FX_CHAR* pStr, uint8_t* pOutBuffer) { j += 3; } } - FDE_Free(pBuffer); + FX_Free(pBuffer); return j; } static FX_CHAR g_base64_chars[] = @@ -979,7 +979,7 @@ CFX_DIBitmap* XFA_LoadImageData(CXFA_FFDoc* pDoc, if (iEncoding == XFA_ATTRIBUTEENUM_Base64) { CFX_ByteString bsData = wsImage.UTF8Encode(); int32_t iLength = bsData.GetLength(); - pImageBuffer = FDE_Alloc(iLength); + pImageBuffer = FX_Alloc(uint8_t, iLength); int32_t iRead = XFA_Base64Decode((const FX_CHAR*)bsData, pImageBuffer); if (iRead > 0) { pImageFileRead = FX_CreateMemoryStream(pImageBuffer, iRead); @@ -1003,17 +1003,13 @@ CFX_DIBitmap* XFA_LoadImageData(CXFA_FFDoc* pDoc, pImageFileRead = pDoc->GetDocProvider()->OpenLinkedFile(pDoc, wsURL); } if (!pImageFileRead) { - if (pImageBuffer) { - FDE_Free(pImageBuffer); - } + FX_Free(pImageBuffer); return NULL; } bNameImage = FALSE; CFX_DIBitmap* pBitmap = XFA_LoadImageFromBuffer(pImageFileRead, type, iImageXDpi, iImageYDpi); - if (pImageBuffer) { - FDE_Free(pImageBuffer); - } + FX_Free(pImageBuffer); pImageFileRead->Release(); return pBitmap; } diff --git a/xfa/src/fxfa/src/app/xfa_textlayout.cpp b/xfa/src/fxfa/src/app/xfa_textlayout.cpp index 12e517de41..efdc116106 100644 --- a/xfa/src/fxfa/src/app/xfa_textlayout.cpp +++ b/xfa/src/fxfa/src/app/xfa_textlayout.cpp @@ -49,9 +49,9 @@ void CXFA_TextParseContext::SetDecls(const IFDE_CSSDeclaration** ppDeclArray, return; } m_dwMatchedDecls = iDeclCount; - int32_t iBytes = iDeclCount * sizeof(IFDE_CSSDeclaration*); - m_ppMatchedDecls = (IFDE_CSSDeclaration**)FDE_Alloc(iBytes); - FX_memcpy(m_ppMatchedDecls, ppDeclArray, iBytes); + m_ppMatchedDecls = FX_Alloc(IFDE_CSSDeclaration*, iDeclCount); + FX_memcpy(m_ppMatchedDecls, ppDeclArray, + iDeclCount * sizeof(IFDE_CSSDeclaration*)); } CXFA_TextParser::~CXFA_TextParser() { if (m_pUASheet != NULL) { @@ -1270,10 +1270,8 @@ FX_BOOL CXFA_TextLayout::DrawString(CFX_RenderDevice* pFxDevice, XFA_LPCTEXTPIECE pPiece = pPieceLine->m_textPieces.GetAt(j); int32_t iChars = pPiece->iChars; if (iCharCount < iChars) { - if (pCharPos != NULL) { - FDE_Free(pCharPos); - } - pCharPos = (FXTEXT_CHARPOS*)FDE_Alloc(iChars * sizeof(FXTEXT_CHARPOS)); + FX_Free(pCharPos); + pCharPos = FX_Alloc(FXTEXT_CHARPOS, iChars); iCharCount = iChars; } FXSYS_memset(pCharPos, 0, iCharCount * sizeof(FXTEXT_CHARPOS)); @@ -1284,9 +1282,7 @@ FX_BOOL CXFA_TextLayout::DrawString(CFX_RenderDevice* pFxDevice, } } pDevice->RestoreState(state); - if (pCharPos != NULL) { - FDE_Free(pCharPos); - } + FX_Free(pCharPos); pSolidBrush->Release(); pPen->Release(); pDevice->Release(); diff --git a/xfa/src/fxfa/src/app/xfa_textlayout.h b/xfa/src/fxfa/src/app/xfa_textlayout.h index a42c27ede8..cbd315993c 100644 --- a/xfa/src/fxfa/src/app/xfa_textlayout.h +++ b/xfa/src/fxfa/src/app/xfa_textlayout.h @@ -49,11 +49,7 @@ class CXFA_TextParseContext : public CFX_Target { m_ppMatchedDecls(nullptr), m_dwMatchedDecls(0), m_eDisplay(FDE_CSSDISPLAY_None) {} - ~CXFA_TextParseContext() { - if (m_ppMatchedDecls != NULL) { - FDE_Free(m_ppMatchedDecls); - } - } + ~CXFA_TextParseContext() { FX_Free(m_ppMatchedDecls); } void SetDisplay(FDE_CSSDISPLAY eDisplay) { m_eDisplay = eDisplay; } FDE_CSSDISPLAY GetDisplay() const { return m_eDisplay; } void SetDecls(const IFDE_CSSDeclaration** ppDeclArray, int32_t iDeclCount); diff --git a/xfa/src/fxfa/src/fm2js/xfa_fm2jscontext.cpp b/xfa/src/fxfa/src/fm2js/xfa_fm2jscontext.cpp index 3412aa258b..bf2aa0ccbe 100644 --- a/xfa/src/fxfa/src/fm2js/xfa_fm2jscontext.cpp +++ b/xfa/src/fxfa/src/fm2js/xfa_fm2jscontext.cpp @@ -5437,12 +5437,10 @@ void CXFA_FM2JSContext::Get(FXJSE_HOBJECT hThis, if (pFile) { int32_t size = pFile->GetSize(); uint8_t* pData = FX_Alloc(uint8_t, size); - if (pData) { - pFile->ReadBlock(pData, size); - FXJSE_Value_SetUTF8String(args.GetReturnValue(), - CFX_ByteStringC(pData, size)); - FX_Free(pData); - } + pFile->ReadBlock(pData, size); + FXJSE_Value_SetUTF8String(args.GetReturnValue(), + CFX_ByteStringC(pData, size)); + FX_Free(pData); pFile->Release(); } FXJSE_Value_Release(argOne); -- cgit v1.2.3