From da180e9fdd4385df024cc18046f62ca47bc74d74 Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Fri, 14 Aug 2015 22:22:13 -0700 Subject: Merge to XFA: Don't bother checking pointers before delete[] and FX_Free(). R=tsepez@chromium.org Review URL: https://codereview.chromium.org/1297713003 . (cherry picked from commit cb62e7657b3a9a04142028a4e6614029a08e894b) Review URL: https://codereview.chromium.org/1287053005 . --- core/src/fxge/android/fpf_skiafontmgr.h | 20 +++------------ core/src/fxge/dib/dib_int.h | 4 +-- core/src/fxge/dib/fx_dib_composite.cpp | 24 +++++------------- core/src/fxge/dib/fx_dib_convert.cpp | 44 +++++++++------------------------ core/src/fxge/dib/fx_dib_engine.cpp | 30 ++++++---------------- core/src/fxge/dib/fx_dib_main.cpp | 22 ++++++----------- core/src/fxge/ge/fx_ge_font.cpp | 12 +++------ core/src/fxge/ge/fx_ge_fontmap.cpp | 4 +-- core/src/fxge/ge/fx_ge_path.cpp | 25 +++++-------------- core/src/fxge/ge/fx_ge_ps.cpp | 4 +-- core/src/fxge/win32/fx_win32_device.cpp | 4 +-- core/src/fxge/win32/fx_win32_print.cpp | 4 +-- 12 files changed, 52 insertions(+), 145 deletions(-) (limited to 'core/src/fxge') diff --git a/core/src/fxge/android/fpf_skiafontmgr.h b/core/src/fxge/android/fpf_skiafontmgr.h index 17bcb48ca1..0b33627cf3 100644 --- a/core/src/fxge/android/fpf_skiafontmgr.h +++ b/core/src/fxge/android/fpf_skiafontmgr.h @@ -24,18 +24,12 @@ class CFPF_SkiaFontDescriptor { m_iFaceIndex(0), m_dwCharsets(0), m_iGlyphNum(0) {} - virtual ~CFPF_SkiaFontDescriptor() { - if (m_pFamily) { - FX_Free(m_pFamily); - } - } + virtual ~CFPF_SkiaFontDescriptor() { FX_Free(m_pFamily); } virtual int32_t GetType() const { return FPF_SKIAFONTTYPE_Unknown; } void SetFamily(const FX_CHAR* pFamily) { - if (m_pFamily) { - FX_Free(m_pFamily); - } + FX_Free(m_pFamily); int32_t iSize = FXSYS_strlen(pFamily); m_pFamily = FX_Alloc(FX_CHAR, iSize + 1); FXSYS_memcpy(m_pFamily, pFamily, iSize * sizeof(FX_CHAR)); @@ -51,19 +45,13 @@ class CFPF_SkiaFontDescriptor { class CFPF_SkiaPathFont : public CFPF_SkiaFontDescriptor { public: CFPF_SkiaPathFont() : m_pPath(NULL) {} - ~CFPF_SkiaPathFont() override { - if (m_pPath) { - FX_Free(m_pPath); - } - } + ~CFPF_SkiaPathFont() override { FX_Free(m_pPath); } // CFPF_SkiaFontDescriptor int32_t GetType() const override { return FPF_SKIAFONTTYPE_Path; } void SetPath(const FX_CHAR* pPath) { - if (m_pPath) { - FX_Free(m_pPath); - } + FX_Free(m_pPath); int32_t iSize = FXSYS_strlen(pPath); m_pPath = FX_Alloc(FX_CHAR, iSize + 1); FXSYS_memcpy(m_pPath, pPath, iSize * sizeof(FX_CHAR)); diff --git a/core/src/fxge/dib/dib_int.h b/core/src/fxge/dib/dib_int.h index 74e77d46da..d40e3a4f95 100644 --- a/core/src/fxge/dib/dib_int.h +++ b/core/src/fxge/dib/dib_int.h @@ -35,9 +35,7 @@ class CWeightTable { public: CWeightTable() { m_pWeightTables = NULL; } ~CWeightTable() { - if (m_pWeightTables) { - FX_Free(m_pWeightTables); - } + FX_Free(m_pWeightTables); m_pWeightTables = NULL; } void Calc(int dest_len, diff --git a/core/src/fxge/dib/fx_dib_composite.cpp b/core/src/fxge/dib/fx_dib_composite.cpp index 84062d80b1..89a52f3dba 100644 --- a/core/src/fxge/dib/fx_dib_composite.cpp +++ b/core/src/fxge/dib/fx_dib_composite.cpp @@ -4193,12 +4193,8 @@ CFX_ScanlineCompositor::CFX_ScanlineCompositor() { m_BlendType = FXDIB_BLEND_NORMAL; } CFX_ScanlineCompositor::~CFX_ScanlineCompositor() { - if (m_pSrcPalette) { - FX_Free(m_pSrcPalette); - } - if (m_pCacheScanline) { - FX_Free(m_pCacheScanline); - } + FX_Free(m_pSrcPalette); + FX_Free(m_pCacheScanline); } FX_BOOL CFX_ScanlineCompositor::Init(FXDIB_Format dest_format, FXDIB_Format src_format, @@ -5010,18 +5006,10 @@ CFX_BitmapComposer::CFX_BitmapComposer() { m_BlendType = FXDIB_BLEND_NORMAL; } CFX_BitmapComposer::~CFX_BitmapComposer() { - if (m_pScanlineV) { - FX_Free(m_pScanlineV); - } - if (m_pScanlineAlphaV) { - FX_Free(m_pScanlineAlphaV); - } - if (m_pClipScanV) { - FX_Free(m_pClipScanV); - } - if (m_pAddClipScan) { - FX_Free(m_pAddClipScan); - } + FX_Free(m_pScanlineV); + FX_Free(m_pScanlineAlphaV); + FX_Free(m_pClipScanV); + FX_Free(m_pAddClipScan); } void CFX_BitmapComposer::Compose(CFX_DIBitmap* pDest, const CFX_ClipRgn* pClipRgn, diff --git a/core/src/fxge/dib/fx_dib_convert.cpp b/core/src/fxge/dib/fx_dib_convert.cpp index 950f72925a..93e741158c 100644 --- a/core/src/fxge/dib/fx_dib_convert.cpp +++ b/core/src/fxge/dib/fx_dib_convert.cpp @@ -202,36 +202,24 @@ CFX_Palette::CFX_Palette() { m_lut = 0; } CFX_Palette::~CFX_Palette() { - if (m_pPalette) { - FX_Free(m_pPalette); - } - if (m_cLut) { - FX_Free(m_cLut); - } - if (m_aLut) { - FX_Free(m_aLut); - } + FX_Free(m_pPalette); + FX_Free(m_cLut); + FX_Free(m_aLut); m_lut = 0; } FX_BOOL CFX_Palette::BuildPalette(const CFX_DIBSource* pBitmap, int pal_type) { if (pBitmap == NULL) { return FALSE; } - if (m_pPalette != NULL) { - FX_Free(m_pPalette); - } + FX_Free(m_pPalette); m_pPalette = FX_Alloc(FX_DWORD, 256); int bpp = pBitmap->GetBPP() / 8; int width = pBitmap->GetWidth(); int height = pBitmap->GetHeight(); - if (m_cLut) { - FX_Free(m_cLut); - m_cLut = NULL; - } - if (m_aLut) { - FX_Free(m_aLut); - m_aLut = NULL; - } + FX_Free(m_cLut); + m_cLut = NULL; + FX_Free(m_aLut); + m_aLut = NULL; m_cLut = FX_Alloc(FX_DWORD, 4096); m_aLut = FX_Alloc(FX_DWORD, 4096); int row, col; @@ -1142,9 +1130,7 @@ CFX_DIBitmap* CFX_DIBSource::CloneConvert(FXDIB_Format dest_format, ret = ConvertBuffer(dest_format, pClone->GetBuffer(), pClone->GetPitch(), m_Width, m_Height, this, 0, 0, pal_8bpp, pIccTransform); if (!ret) { - if (pal_8bpp) { - FX_Free(pal_8bpp); - } + FX_Free(pal_8bpp); delete pClone; return NULL; } @@ -1222,24 +1208,18 @@ FX_BOOL CFX_DIBitmap::ConvertFormat(FXDIB_Format dest_format, ret = ConvertBuffer(dest_format, dest_buf, dest_pitch, m_Width, m_Height, this, 0, 0, pal_8bpp, pIccTransform); if (!ret) { - if (pal_8bpp) { - FX_Free(pal_8bpp); - } + FX_Free(pal_8bpp); if (pAlphaMask != m_pAlphaMask) { delete pAlphaMask; } - if (dest_buf) { - FX_Free(dest_buf); - } + FX_Free(dest_buf); return FALSE; } if (m_pAlphaMask && pAlphaMask != m_pAlphaMask) { delete m_pAlphaMask; } m_pAlphaMask = pAlphaMask; - if (m_pPalette) { - FX_Free(m_pPalette); - } + FX_Free(m_pPalette); m_pPalette = pal_8bpp; if (!m_bExtBuf) { FX_Free(m_pBuffer); diff --git a/core/src/fxge/dib/fx_dib_engine.cpp b/core/src/fxge/dib/fx_dib_engine.cpp index ce95a6e9ad..b2da83a802 100644 --- a/core/src/fxge/dib/fx_dib_engine.cpp +++ b/core/src/fxge/dib/fx_dib_engine.cpp @@ -16,10 +16,8 @@ void CWeightTable::Calc(int dest_len, int src_min, int src_max, int flags) { - if (m_pWeightTables) { - FX_Free(m_pWeightTables); - m_pWeightTables = NULL; - } + FX_Free(m_pWeightTables); + m_pWeightTables = NULL; double scale, base; scale = FXSYS_Div((FX_FLOAT)(src_len), (FX_FLOAT)(dest_len)); if (dest_len < 0) { @@ -334,18 +332,10 @@ FX_BOOL CStretchEngine::Continue(IFX_Pause* pPause) { return FALSE; } CStretchEngine::~CStretchEngine() { - if (m_pDestScanline) { - FX_Free(m_pDestScanline); - } - if (m_pInterBuf) { - FX_Free(m_pInterBuf); - } - if (m_pExtraAlphaBuf) { - FX_Free(m_pExtraAlphaBuf); - } - if (m_pDestMaskScanline) { - FX_Free(m_pDestMaskScanline); - } + FX_Free(m_pDestScanline); + FX_Free(m_pInterBuf); + FX_Free(m_pExtraAlphaBuf); + FX_Free(m_pDestMaskScanline); } FX_BOOL CStretchEngine::StartStretchHorz() { if (m_DestWidth == 0 || m_pDestScanline == NULL || @@ -769,13 +759,9 @@ CFX_ImageStretcher::CFX_ImageStretcher() { m_pMaskScanline = NULL; } CFX_ImageStretcher::~CFX_ImageStretcher() { - if (m_pScanline) { - FX_Free(m_pScanline); - } + FX_Free(m_pScanline); delete m_pStretchEngine; - if (m_pMaskScanline) { - FX_Free(m_pMaskScanline); - } + FX_Free(m_pMaskScanline); } FXDIB_Format _GetStretchedFormat(const CFX_DIBSource* pSrc) { FXDIB_Format format = pSrc->GetFormat(); diff --git a/core/src/fxge/dib/fx_dib_main.cpp b/core/src/fxge/dib/fx_dib_main.cpp index ce55640cb3..f3e3a23236 100644 --- a/core/src/fxge/dib/fx_dib_main.cpp +++ b/core/src/fxge/dib/fx_dib_main.cpp @@ -48,9 +48,7 @@ CFX_DIBSource::CFX_DIBSource() { m_pAlphaMask = NULL; } CFX_DIBSource::~CFX_DIBSource() { - if (m_pPalette) { - FX_Free(m_pPalette); - } + FX_Free(m_pPalette); delete m_pAlphaMask; } CFX_DIBitmap::CFX_DIBitmap() { @@ -102,7 +100,7 @@ FX_BOOL CFX_DIBitmap::Create(int width, FX_BOOL ret = TRUE; ret = BuildAlphaMask(); if (!ret) { - if (!m_bExtBuf && m_pBuffer) { + if (!m_bExtBuf) { FX_Free(m_pBuffer); m_pBuffer = NULL; m_Width = m_Height = m_Pitch = 0; @@ -127,18 +125,16 @@ FX_BOOL CFX_DIBitmap::Copy(const CFX_DIBSource* pSrc) { return TRUE; } CFX_DIBitmap::~CFX_DIBitmap() { - if (m_pBuffer && !m_bExtBuf) { + if (!m_bExtBuf) { FX_Free(m_pBuffer); } m_pBuffer = NULL; } void CFX_DIBitmap::TakeOver(CFX_DIBitmap* pSrcBitmap) { - if (m_pBuffer && !m_bExtBuf) { + if (!m_bExtBuf) { FX_Free(m_pBuffer); } - if (m_pPalette) { - FX_Free(m_pPalette); - } + FX_Free(m_pPalette); delete m_pAlphaMask; m_pBuffer = pSrcBitmap->m_pBuffer; m_pPalette = pSrcBitmap->m_pPalette; @@ -548,9 +544,7 @@ FX_BOOL CFX_DIBitmap::TransferMask(int dest_left, } void CFX_DIBSource::CopyPalette(const FX_DWORD* pSrc, FX_DWORD size) { if (pSrc == NULL || GetBPP() > 8) { - if (m_pPalette) { - FX_Free(m_pPalette); - } + FX_Free(m_pPalette); m_pPalette = NULL; } else { FX_DWORD pal_size = 1 << GetBPP(); @@ -1546,9 +1540,7 @@ CFX_FilteredDIB::~CFX_FilteredDIB() { if (m_bAutoDropSrc) { delete m_pSrc; } - if (m_pScanline) { - FX_Free(m_pScanline); - } + FX_Free(m_pScanline); } void CFX_FilteredDIB::LoadSrc(const CFX_DIBSource* pSrc, FX_BOOL bAutoDropSrc) { m_pSrc = pSrc; diff --git a/core/src/fxge/ge/fx_ge_font.cpp b/core/src/fxge/ge/fx_ge_font.cpp index d428494913..63e9b52954 100644 --- a/core/src/fxge/ge/fx_ge_font.cpp +++ b/core/src/fxge/ge/fx_ge_font.cpp @@ -77,14 +77,10 @@ CFX_Font::~CFX_Font() { CFX_GEModule::Get()->GetFontMgr()->ReleaseFace(m_Face); } } - if (m_pOwnedStream) { - FX_Free(m_pOwnedStream); - m_pOwnedStream = NULL; - } - if (m_pGsubData) { - FX_Free(m_pGsubData); - m_pGsubData = NULL; - } + FX_Free(m_pOwnedStream); + m_pOwnedStream = NULL; + FX_Free(m_pGsubData); + m_pGsubData = NULL; #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ ReleasePlatformResource(); #endif diff --git a/core/src/fxge/ge/fx_ge_fontmap.cpp b/core/src/fxge/ge/fx_ge_fontmap.cpp index eefeb5d618..f755b69072 100644 --- a/core/src/fxge/ge/fx_ge_fontmap.cpp +++ b/core/src/fxge/ge/fx_ge_fontmap.cpp @@ -33,9 +33,7 @@ CTTFontDesc::~CTTFontDesc() { FXFT_Done_Face(m_TTCFace.m_pFaces[i]); } } - if (m_pFontData) { - FX_Free(m_pFontData); - } + FX_Free(m_pFontData); } int32_t CTTFontDesc::ReleaseFace(FXFT_Face face) { if (m_Type == 1) { diff --git a/core/src/fxge/ge/fx_ge_path.cpp b/core/src/fxge/ge/fx_ge_path.cpp index b50c271c20..9acbcabfbf 100644 --- a/core/src/fxge/ge/fx_ge_path.cpp +++ b/core/src/fxge/ge/fx_ge_path.cpp @@ -117,17 +117,12 @@ CFX_PathData::CFX_PathData() { m_pPoints = NULL; } CFX_PathData::~CFX_PathData() { - if (m_pPoints) { - FX_Free(m_pPoints); - } + FX_Free(m_pPoints); } void CFX_PathData::SetPointCount(int nPoints) { m_PointCount = nPoints; if (m_AllocCount < nPoints) { - if (m_pPoints) { - FX_Free(m_pPoints); - m_pPoints = NULL; - } + FX_Free(m_pPoints); m_pPoints = FX_Alloc(FX_PATHPOINT, nPoints); m_AllocCount = nPoints; } @@ -138,9 +133,7 @@ void CFX_PathData::AllocPointCount(int nPoints) { if (m_PointCount) { FXSYS_memcpy(pNewBuf, m_pPoints, m_PointCount * sizeof(FX_PATHPOINT)); } - if (m_pPoints) { - FX_Free(m_pPoints); - } + FX_Free(m_pPoints); m_pPoints = pNewBuf; m_AllocCount = nPoints; } @@ -640,9 +633,7 @@ CFX_GraphStateData::CFX_GraphStateData(const CFX_GraphStateData& src) { void CFX_GraphStateData::Copy(const CFX_GraphStateData& src) { m_LineCap = src.m_LineCap; m_DashCount = src.m_DashCount; - if (m_DashArray) { - FX_Free(m_DashArray); - } + FX_Free(m_DashArray); m_DashArray = NULL; m_DashPhase = src.m_DashPhase; m_LineJoin = src.m_LineJoin; @@ -654,14 +645,10 @@ void CFX_GraphStateData::Copy(const CFX_GraphStateData& src) { } } CFX_GraphStateData::~CFX_GraphStateData() { - if (m_DashArray) { - FX_Free(m_DashArray); - } + FX_Free(m_DashArray); } void CFX_GraphStateData::SetDashCount(int count) { - if (m_DashArray) { - FX_Free(m_DashArray); - } + FX_Free(m_DashArray); m_DashArray = NULL; m_DashCount = count; if (count == 0) { diff --git a/core/src/fxge/ge/fx_ge_ps.cpp b/core/src/fxge/ge/fx_ge_ps.cpp index 5a97d5b18b..34dbde2b2d 100644 --- a/core/src/fxge/ge/fx_ge_ps.cpp +++ b/core/src/fxge/ge/fx_ge_ps.cpp @@ -322,9 +322,7 @@ static void PSCompressData(int PSLevel, output_size = dest_size; } else { filter = NULL; - if (dest_buf) { - FX_Free(dest_buf); - } + FX_Free(dest_buf); } } FX_BOOL CFX_PSRenderer::SetDIBits(const CFX_DIBSource* pSource, diff --git a/core/src/fxge/win32/fx_win32_device.cpp b/core/src/fxge/win32/fx_win32_device.cpp index eca2b0440b..d5f29686c9 100644 --- a/core/src/fxge/win32/fx_win32_device.cpp +++ b/core/src/fxge/win32/fx_win32_device.cpp @@ -702,9 +702,7 @@ static HPEN _CreatePen(const CFX_GraphStateData* pGraphState, } HPEN hPen = ExtCreatePen(PenStyle, (DWORD)FXSYS_ceil(width), &lb, pGraphState->m_DashCount, (const DWORD*)pDash); - if (pDash) { - FX_Free(pDash); - } + FX_Free(pDash); return hPen; } static HBRUSH _CreateBrush(FX_DWORD argb) { diff --git a/core/src/fxge/win32/fx_win32_print.cpp b/core/src/fxge/win32/fx_win32_print.cpp index aa8eefd1bb..de5b4c54be 100644 --- a/core/src/fxge/win32/fx_win32_print.cpp +++ b/core/src/fxge/win32/fx_win32_print.cpp @@ -289,9 +289,7 @@ CPSOutput::CPSOutput(HDC hDC) { m_pBuf = NULL; } CPSOutput::~CPSOutput() { - if (m_pBuf) { - FX_Free(m_pBuf); - } + FX_Free(m_pBuf); } void CPSOutput::Init() { m_pBuf = FX_Alloc(FX_CHAR, 1026); -- cgit v1.2.3