diff options
author | Tom Sepez <tsepez@chromium.org> | 2015-12-17 10:37:41 -0800 |
---|---|---|
committer | Tom Sepez <tsepez@chromium.org> | 2015-12-17 10:37:41 -0800 |
commit | 1871821653de9f4b1706d726f4d318cf739e55af (patch) | |
tree | 20e58a8f34ced5656e4a8d26d813737b2810e9f8 /xfa/src/fdp | |
parent | fc75136232f1979217d7597b2c9c5966436eb1e1 (diff) | |
download | pdfium-1871821653de9f4b1706d726f4d318cf739e55af.tar.xz |
Remove FDE_Alloc in favor of FX_Alloc.
R=thestig@chromium.org
Review URL: https://codereview.chromium.org/1521163002 .
Diffstat (limited to 'xfa/src/fdp')
-rw-r--r-- | xfa/src/fdp/include/fde_mem.h | 16 | ||||
-rw-r--r-- | xfa/src/fdp/src/css/fde_csssyntax.cpp | 19 | ||||
-rw-r--r-- | xfa/src/fdp/src/fde/fde_gdidevice.cpp | 8 | ||||
-rw-r--r-- | xfa/src/fdp/src/fde/fde_gedevice.cpp | 7 | ||||
-rw-r--r-- | xfa/src/fdp/src/fde/fde_render.cpp | 21 | ||||
-rw-r--r-- | xfa/src/fdp/src/tto/fde_textout.cpp | 41 | ||||
-rw-r--r-- | xfa/src/fdp/src/xml/fde_xml.cpp | 63 |
7 files changed, 63 insertions, 112 deletions
diff --git a/xfa/src/fdp/include/fde_mem.h b/xfa/src/fdp/include/fde_mem.h index d16bb53d26..c05ab8e85b 100644 --- a/xfa/src/fdp/include/fde_mem.h +++ b/xfa/src/fdp/include/fde_mem.h @@ -4,20 +4,12 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#ifndef _FDE_MEM
-#define _FDE_MEM
+#ifndef FDE_MEM_H_
+#define FDE_MEM_H_
#include "../../../../core/include/fxcrt/fx_memory.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-#define FDE_Alloc(size) FX_Alloc(uint8_t, size)
-#define FDE_Realloc(ptr, newSize) FX_Realloc(uint8_t, ptr, newSize)
-#define FDE_Free(ptr) FX_Free(ptr)
-#ifdef __cplusplus
-}
#define FDE_NewWith FXTARGET_NewWith
#define FDE_DeleteWith FXTARGET_DeleteWith
-#endif
-#endif
+
+#endif // FDE_MEM_H_
diff --git a/xfa/src/fdp/src/css/fde_csssyntax.cpp b/xfa/src/fdp/src/css/fde_csssyntax.cpp index dea453ff03..7d540bb623 100644 --- a/xfa/src/fdp/src/css/fde_csssyntax.cpp +++ b/xfa/src/fdp/src/css/fde_csssyntax.cpp @@ -415,8 +415,8 @@ CFDE_CSSTextBuf::~CFDE_CSSTextBuf() { Reset();
}
void CFDE_CSSTextBuf::Reset() {
- if (!m_bExtBuf && m_pBuffer != NULL) {
- FDE_Free(m_pBuffer);
+ if (!m_bExtBuf) {
+ FX_Free(m_pBuffer);
m_pBuffer = NULL;
}
m_iDatPos = m_iDatLen = m_iBufLen;
@@ -455,21 +455,20 @@ int32_t CFDE_CSSTextBuf::LoadFromStream(IFX_Stream* pTxtStream, FX_BOOL CFDE_CSSTextBuf::ExpandBuf(int32_t iDesiredSize) {
if (m_bExtBuf) {
return FALSE;
- } else if (m_pBuffer == NULL) {
- m_pBuffer = (FX_WCHAR*)FDE_Alloc(iDesiredSize * sizeof(FX_WCHAR));
+ }
+ if (!m_pBuffer) {
+ m_pBuffer = FX_Alloc(FX_WCHAR, iDesiredSize);
} else if (m_iBufLen != iDesiredSize) {
- m_pBuffer =
- (FX_WCHAR*)FDE_Realloc(m_pBuffer, iDesiredSize * sizeof(FX_WCHAR));
+ m_pBuffer = FX_Realloc(FX_WCHAR, m_pBuffer, iDesiredSize);
} else {
return TRUE;
}
- if (m_pBuffer == NULL) {
+ if (!m_pBuffer) {
m_iBufLen = 0;
return FALSE;
- } else {
- m_iBufLen = iDesiredSize;
- return TRUE;
}
+ m_iBufLen = iDesiredSize;
+ return TRUE;
}
void CFDE_CSSTextBuf::Subtract(int32_t iStart, int32_t iLength) {
FXSYS_assert(iStart >= 0 && iLength > 0);
diff --git a/xfa/src/fdp/src/fde/fde_gdidevice.cpp b/xfa/src/fdp/src/fde/fde_gdidevice.cpp index 10a50868e3..0035f6b866 100644 --- a/xfa/src/fdp/src/fde/fde_gdidevice.cpp +++ b/xfa/src/fdp/src/fde/fde_gdidevice.cpp @@ -42,9 +42,7 @@ CFDE_GdiDevice::CFDE_GdiDevice(CFX_DIBitmap* pBitmap) CFDE_GdiDevice::~CFDE_GdiDevice() {
delete m_pGraphics;
delete m_pBitmap;
- if (m_pGlyphBuf) {
- FDE_Free(m_pGlyphBuf);
- }
+ FX_Free(m_pGlyphBuf);
}
int32_t CFDE_GdiDevice::GetWidth() const {
return m_pBitmap->GetWidth();
@@ -193,10 +191,10 @@ FX_BOOL CFDE_GdiDevice::DrawString(IFDE_Brush* pBrush, &mat2, gm, NULL, 0);
if (dwSize > 0) {
if (m_pGlyphBuf == NULL) {
- m_pGlyphBuf = FDE_Alloc(dwSize);
+ m_pGlyphBuf = FX_Alloc(uint8_t, dwSize);
m_dwGlyphLen = dwSize;
} else if (m_dwGlyphLen < dwSize) {
- m_pGlyphBuf = FDE_Realloc(m_pGlyphBuf, dwSize);
+ m_pGlyphBuf = FX_Realloc(uint8_t, m_pGlyphBuf, dwSize);
m_dwGlyphLen = dwSize;
}
pGdiFont->GetGlyphDIBits(pCharPos->m_GlyphIndex, argb, &mat2, gm,
diff --git a/xfa/src/fdp/src/fde/fde_gedevice.cpp b/xfa/src/fdp/src/fde/fde_gedevice.cpp index 23da752e3b..8eb325ee02 100644 --- a/xfa/src/fdp/src/fde/fde_gedevice.cpp +++ b/xfa/src/fdp/src/fde/fde_gedevice.cpp @@ -49,12 +49,9 @@ CFDE_FxgeDevice::CFDE_FxgeDevice(CFX_RenderDevice* pDevice, (FX_FLOAT)rt.Height());
}
CFDE_FxgeDevice::~CFDE_FxgeDevice() {
- if (m_pCharPos != NULL) {
- FDE_Free(m_pCharPos);
- }
- if (m_bOwnerDevice && m_pDevice) {
+ FX_Free(m_pCharPos);
+ if (m_bOwnerDevice)
delete m_pDevice;
- }
}
int32_t CFDE_FxgeDevice::GetWidth() const {
return m_pDevice->GetWidth();
diff --git a/xfa/src/fdp/src/fde/fde_render.cpp b/xfa/src/fdp/src/fde/fde_render.cpp index af5b0e848d..f47c9fef76 100644 --- a/xfa/src/fdp/src/fde/fde_render.cpp +++ b/xfa/src/fdp/src/fde/fde_render.cpp @@ -158,20 +158,18 @@ FDE_RENDERSTATUS CFDE_RenderContext::DoRender(IFX_Pause* pPause) { void CFDE_RenderContext::StopRender() {
Lock();
m_eStatus = FDE_RENDERSTATUS_Reset;
- m_pRenderDevice = NULL;
+ m_pRenderDevice = nullptr;
m_Transform.SetIdentity();
- if (m_pIterator != NULL) {
+ if (m_pIterator) {
m_pIterator->Release();
- m_pIterator = NULL;
+ m_pIterator = nullptr;
}
- if (m_pSolidBrush != NULL) {
+ if (m_pSolidBrush) {
m_pSolidBrush->Release();
- m_pSolidBrush = NULL;
- }
- if (m_pCharPos != NULL) {
- FDE_Free(m_pCharPos);
- m_pCharPos = NULL;
+ m_pSolidBrush = nullptr;
}
+ FX_Free(m_pCharPos);
+ m_pCharPos = nullptr;
m_iCharPosCount = 0;
Unlock();
}
@@ -194,10 +192,9 @@ void CFDE_RenderContext::RenderText(IFDE_TextSet* pTextSet, }
}
if (m_pCharPos == NULL) {
- m_pCharPos = (FXTEXT_CHARPOS*)FDE_Alloc(sizeof(FXTEXT_CHARPOS) * iCount);
+ m_pCharPos = FX_Alloc(FXTEXT_CHARPOS, iCount);
} else if (m_iCharPosCount < iCount) {
- m_pCharPos = (FXTEXT_CHARPOS*)FDE_Realloc(m_pCharPos,
- sizeof(FXTEXT_CHARPOS) * iCount);
+ m_pCharPos = FX_Realloc(FXTEXT_CHARPOS, m_pCharPos, iCount);
}
if (m_iCharPosCount < iCount) {
m_iCharPosCount = iCount;
diff --git a/xfa/src/fdp/src/tto/fde_textout.cpp b/xfa/src/fdp/src/tto/fde_textout.cpp index a1ef69ac42..9781c7f943 100644 --- a/xfa/src/fdp/src/tto/fde_textout.cpp +++ b/xfa/src/fdp/src/tto/fde_textout.cpp @@ -41,25 +41,19 @@ CFDE_TextOut::CFDE_TextOut() m_rtLogicClip.Reset();
}
CFDE_TextOut::~CFDE_TextOut() {
- if (m_pTxtBreak != NULL) {
+ if (m_pTxtBreak) {
m_pTxtBreak->Release();
}
- if (m_pCharWidths != NULL) {
- FDE_Free(m_pCharWidths);
- }
- if (m_pEllCharWidths != NULL) {
- FDE_Free(m_pEllCharWidths);
- }
- if (m_pRenderDevice != NULL) {
+ FX_Free(m_pCharWidths);
+ FX_Free(m_pEllCharWidths);
+ if (m_pRenderDevice) {
m_pRenderDevice->Release();
}
- if (m_pCharPos != NULL) {
- FDE_Free(m_pCharPos);
- }
+ FX_Free(m_pCharPos);
m_ttoLines.RemoveAll();
}
void CFDE_TextOut::SetFont(IFX_Font* pFont) {
- FXSYS_assert(pFont != NULL);
+ FXSYS_assert(pFont);
m_pFont = pFont;
m_pTxtBreak->SetFont(pFont);
}
@@ -415,34 +409,31 @@ void CFDE_TextOut::DrawText(const FX_WCHAR* pwsStr, void CFDE_TextOut::ExpandBuffer(int32_t iSize, int32_t iType) {
switch (iType) {
case 0:
- if (m_pCharWidths == NULL) {
- m_pCharWidths = (int32_t*)FDE_Alloc(iSize * sizeof(int32_t));
+ if (!m_pCharWidths) {
+ m_pCharWidths = FX_Alloc(int32_t, iSize);
m_iChars = iSize;
} else if (m_iChars < iSize) {
- m_pCharWidths =
- (int32_t*)FDE_Realloc(m_pCharWidths, iSize * sizeof(int32_t));
+ m_pCharWidths = FX_Realloc(int32_t, m_pCharWidths, iSize);
m_iChars = iSize;
}
- FXSYS_memset(m_pCharWidths, 0, iSize);
+ FXSYS_memset(m_pCharWidths, 0, iSize * sizeof(int32_t));
break;
case 1:
- if (m_pEllCharWidths == NULL) {
- m_pEllCharWidths = (int32_t*)FDE_Alloc(iSize * sizeof(int32_t));
+ if (!m_pEllCharWidths) {
+ m_pEllCharWidths = FX_Alloc(int32_t, iSize);
m_iEllChars = iSize;
} else if (m_iEllChars < iSize) {
- m_pEllCharWidths =
- (int32_t*)FDE_Realloc(m_pEllCharWidths, iSize * sizeof(int32_t));
+ m_pEllCharWidths = FX_Realloc(int32_t, m_pEllCharWidths, iSize);
m_iEllChars = iSize;
}
- FXSYS_memset(m_pEllCharWidths, 0, iSize);
+ FXSYS_memset(m_pEllCharWidths, 0, iSize * sizeof(int32_t));
break;
case 2:
if (m_pCharPos == NULL) {
- m_pCharPos = (FXTEXT_CHARPOS*)FDE_Alloc(iSize * sizeof(FXTEXT_CHARPOS));
+ m_pCharPos = FX_Alloc(FXTEXT_CHARPOS, iSize);
m_iCharPosSize = iSize;
} else if (m_iCharPosSize < iSize) {
- m_pCharPos = (FXTEXT_CHARPOS*)FDE_Realloc(
- m_pCharPos, iSize * sizeof(FXTEXT_CHARPOS));
+ m_pCharPos = FX_Realloc(FXTEXT_CHARPOS, m_pCharPos, iSize);
m_iCharPosSize = iSize;
}
break;
diff --git a/xfa/src/fdp/src/xml/fde_xml.cpp b/xfa/src/fdp/src/xml/fde_xml.cpp index 66a4eeb2b8..00a3bf24eb 100644 --- a/xfa/src/fdp/src/xml/fde_xml.cpp +++ b/xfa/src/fdp/src/xml/fde_xml.cpp @@ -1325,39 +1325,24 @@ CFDE_BlockBuffer::~CFDE_BlockBuffer() { }
FX_WCHAR* CFDE_BlockBuffer::GetAvailableBlock(int32_t& iIndexInBlock) {
iIndexInBlock = 0;
- int32_t iBlockNum = m_BlockArray.GetSize();
- if (iBlockNum == 0) {
- return NULL;
+ if (!m_BlockArray.GetSize()) {
+ return nullptr;
}
int32_t iRealIndex = m_iStartPosition + m_iDataLength;
- FX_WCHAR* pDataBlock = NULL;
if (iRealIndex == m_iBufferSize) {
- FX_WCHAR* pBlock = (FX_WCHAR*)FDE_Alloc(m_iAllocStep * sizeof(FX_WCHAR));
- if (pBlock) {
- m_BlockArray.Add(pBlock);
- m_iBufferSize += m_iAllocStep;
- }
- iIndexInBlock = 0;
- pDataBlock = pBlock;
- } else {
- int32_t iBlockIndex = iRealIndex / m_iAllocStep;
- int32_t iInnerIndex = iRealIndex % m_iAllocStep;
- iIndexInBlock = iInnerIndex;
- pDataBlock = (FX_WCHAR*)m_BlockArray[iBlockIndex];
+ FX_WCHAR* pBlock = FX_Alloc(FX_WCHAR, m_iAllocStep);
+ m_BlockArray.Add(pBlock);
+ m_iBufferSize += m_iAllocStep;
+ return pBlock;
}
- return pDataBlock;
+ iIndexInBlock = iRealIndex % m_iAllocStep;
+ return (FX_WCHAR*)m_BlockArray[iRealIndex / m_iAllocStep];
}
FX_BOOL CFDE_BlockBuffer::InitBuffer(int32_t iBufferSize) {
ClearBuffer();
int32_t iNumOfBlock = (iBufferSize - 1) / m_iAllocStep + 1;
for (int32_t i = 0; i < iNumOfBlock; i++) {
- FX_WCHAR* pBlockBuffer =
- (FX_WCHAR*)FDE_Alloc(m_iAllocStep * sizeof(FX_WCHAR));
- if (pBlockBuffer == NULL) {
- ClearBuffer();
- return FALSE;
- }
- m_BlockArray.Add(pBlockBuffer);
+ m_BlockArray.Add(FX_Alloc(FX_WCHAR, m_iAllocStep));
}
m_iBufferSize = iNumOfBlock * m_iAllocStep;
return TRUE;
@@ -1373,10 +1358,7 @@ void CFDE_BlockBuffer::SetTextChar(int32_t iIndex, FX_WCHAR ch) { if (iBlockIndex >= iBlockSize) {
int32_t iNewBlocks = iBlockIndex - iBlockSize + 1;
do {
- FX_WCHAR* pBlock = (FX_WCHAR*)FDE_Alloc(m_iAllocStep * sizeof(FX_WCHAR));
- if (!pBlock) {
- return;
- }
+ FX_WCHAR* pBlock = FX_Alloc(FX_WCHAR, m_iAllocStep);
m_BlockArray.Add(pBlock);
m_iBufferSize += m_iAllocStep;
} while (--iNewBlocks);
@@ -1457,7 +1439,7 @@ void CFDE_BlockBuffer::ClearBuffer() { m_iBufferSize = 0;
int32_t iSize = m_BlockArray.GetSize();
for (int32_t i = 0; i < iSize; i++) {
- FDE_Free(m_BlockArray[i]);
+ FX_Free(m_BlockArray[i]);
m_BlockArray[i] = NULL;
}
m_BlockArray.RemoveAll();
@@ -1506,7 +1488,7 @@ void CFDE_XMLSyntaxParser::Init(IFX_Stream* pStream, uint8_t bom[4];
m_iCurrentPos = m_pStream->GetBOM(bom);
FXSYS_assert(m_pBuffer == NULL);
- m_pBuffer = (FX_WCHAR*)FDE_Alloc(m_iXMLPlaneSize * sizeof(FX_WCHAR));
+ m_pBuffer = FX_Alloc(FX_WCHAR, m_iXMLPlaneSize);
m_pStart = m_pEnd = m_pBuffer;
FXSYS_assert(!m_BlockBuffer.IsInitialized());
m_BlockBuffer.InitBuffer();
@@ -1519,8 +1501,7 @@ FX_DWORD CFDE_XMLSyntaxParser::DoSyntaxParse() { m_dwStatus == FDE_XMLSYNTAXSTATUS_EOS) {
return m_dwStatus;
}
- FXSYS_assert(m_pStream != NULL && m_pBuffer != NULL &&
- m_BlockBuffer.IsInitialized());
+ FXSYS_assert(m_pStream && m_pBuffer && m_BlockBuffer.IsInitialized());
int32_t iStreamLength = m_pStream->GetLength();
int32_t iPos;
FX_WCHAR ch;
@@ -2026,11 +2007,12 @@ void CFDE_XMLSyntaxParser::Init(IFX_Stream* pStream, uint8_t bom[4];
m_iCurrentPos = m_pStream->GetBOM(bom);
FXSYS_assert(m_pBuffer == NULL);
- m_pBuffer = (FX_WCHAR*)FDE_Alloc(m_iXMLPlaneSize * sizeof(FX_WCHAR));
+ m_pBuffer = FX_Alloc(FX_WCHAR, m_iXMLPlaneSize);
m_pStart = m_pEnd = m_pBuffer;
FXSYS_assert(m_pwsTextData == NULL);
- m_pwsTextData = (FX_WCHAR*)FDE_Alloc(m_iTextDataSize * sizeof(FX_WCHAR));
- m_iParsedBytes = m_iParsedChars = 0;
+ m_pwsTextData = FX_Alloc(FX_WCHAR, m_iTextDataSize);
+ m_iParsedBytes = 0;
+ m_iParsedChars = 0;
m_iBufferChars = 0;
}
FX_DWORD CFDE_XMLSyntaxParser::DoSyntaxParse() {
@@ -2449,13 +2431,9 @@ CFDE_XMLSyntaxParser::~CFDE_XMLSyntaxParser() { m_pCurrentBlock = NULL;
}
#else
- if (m_pwsTextData != NULL) {
- FDE_Free(m_pwsTextData);
- }
+ FX_Free(m_pwsTextData);
#endif
- if (m_pBuffer != NULL) {
- FDE_Free(m_pBuffer);
- }
+ FX_Free(m_pBuffer);
}
int32_t CFDE_XMLSyntaxParser::GetStatus() const {
if (m_pStream == NULL) {
@@ -2648,8 +2626,7 @@ void CFDE_XMLSyntaxParser::ReallocTextDataBuffer() { } else {
m_iTextDataSize += 1024 * 1024;
}
- m_pwsTextData =
- (FX_WCHAR*)FDE_Realloc(m_pwsTextData, m_iTextDataSize * sizeof(FX_WCHAR));
+ m_pwsTextData = FX_Realloc(FX_WCHAR, m_pwsTextData, m_iTextDataSize);
}
void CFDE_XMLSyntaxParser::GetData(CFX_WideString& wsData) const {
FX_WCHAR* pBuf = wsData.GetBuffer(m_iTextDataLength);
|