diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-01-31 14:46:38 +0200 |
---|---|---|
committer | Ashod Nakashian <ashod.nakashian@collabora.co.uk> | 2017-12-05 08:17:11 -0500 |
commit | 9ca19666511b1d44ba554a70cbbc0c8e2db844c6 (patch) | |
tree | 39a0bd694d2f1cf5d5a67082b85717e5bb2cbef0 /vcl | |
parent | 6346e8c08e789e6aa4f2041fab97ba14419dedd4 (diff) |
loplugin:useuniqueptr extend to check local vars
just the simple and obvious case for now, of a local var being allocated
and deleted inside a single local block, and the delete happening at the
end of the block
Reviewed-on: https://gerrit.libreoffice.org/33749
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
(cherry picked from commit 2489000d3fd66319a8355fd4e37cfdfda47296d0)
Change-Id: I3a7a094da543debdcd2374737c2ecff91d644625
(cherry picked from commit e540ccfb5eb43bd4a3d6920074dce8436720ba8e)
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/source/gdi/bitmap4.cxx | 6 | ||||
-rw-r--r-- | vcl/source/gdi/impgraph.cxx | 8 | ||||
-rw-r--r-- | vcl/source/gdi/salgdilayout.cxx | 10 |
3 files changed, 8 insertions, 16 deletions
diff --git a/vcl/source/gdi/bitmap4.cxx b/vcl/source/gdi/bitmap4.cxx index e516541148af..b60644fb439a 100644 --- a/vcl/source/gdi/bitmap4.cxx +++ b/vcl/source/gdi/bitmap4.cxx @@ -748,8 +748,8 @@ bool Bitmap::ImplSepia( const BmpFilterParam* pFilterParam ) { for( long nY = 0; nY < nHeight ; nY++ ) { - const sal_uInt16 nPalCount = pReadAcc->GetPaletteEntryCount(); - sal_uInt8* pIndexMap = new sal_uInt8[ nPalCount ]; + const sal_uInt16 nPalCount = pReadAcc->GetPaletteEntryCount(); + std::unique_ptr<sal_uInt8[]> pIndexMap( new sal_uInt8[ nPalCount ] ); for( sal_uInt16 i = 0; i < nPalCount; i++ ) pIndexMap[ i ] = pReadAcc->GetPaletteColor( i ).GetLuminance(); @@ -759,8 +759,6 @@ bool Bitmap::ImplSepia( const BmpFilterParam* pFilterParam ) aCol.SetIndex( pIndexMap[ pReadAcc->GetPixel( nY, nX ).GetIndex() ] ); pWriteAcc->SetPixel( nY, nX, aCol ); } - - delete[] pIndexMap; } } else diff --git a/vcl/source/gdi/impgraph.cxx b/vcl/source/gdi/impgraph.cxx index a1dfcf7e8e18..72b96fc397ff 100644 --- a/vcl/source/gdi/impgraph.cxx +++ b/vcl/source/gdi/impgraph.cxx @@ -923,15 +923,13 @@ bool ImpGraphic::ImplReadEmbedded( SvStream& rIStm ) if( GRAPHIC_FORMAT_50 == nId ) { // read new style header - VersionCompat* pCompat = new VersionCompat( rIStm, StreamMode::READ ); + std::unique_ptr<VersionCompat> pCompat( new VersionCompat( rIStm, StreamMode::READ ) ); rIStm.ReadInt32( nType ); sal_Int32 nLen; rIStm.ReadInt32( nLen ); ReadPair( rIStm, aSize ); ReadMapMode( rIStm, aMapMode ); - - delete pCompat; } else { @@ -1060,7 +1058,7 @@ bool ImpGraphic::ImplWriteEmbedded( SvStream& rOStm ) rOStm.WriteUInt32( GRAPHIC_FORMAT_50 ); // write new style header - VersionCompat* pCompat = new VersionCompat( rOStm, StreamMode::WRITE, 1 ); + std::unique_ptr<VersionCompat> pCompat( new VersionCompat( rOStm, StreamMode::WRITE, 1 ) ); rOStm.WriteInt32( (sal_Int32)meType ); @@ -1070,8 +1068,6 @@ bool ImpGraphic::ImplWriteEmbedded( SvStream& rOStm ) WritePair( rOStm, aSize ); WriteMapMode( rOStm, aMapMode ); - - delete pCompat; } else { diff --git a/vcl/source/gdi/salgdilayout.cxx b/vcl/source/gdi/salgdilayout.cxx index ccc832f7a23a..314b42cd8a41 100644 --- a/vcl/source/gdi/salgdilayout.cxx +++ b/vcl/source/gdi/salgdilayout.cxx @@ -419,7 +419,7 @@ void SalGraphics::DrawPolyPolygon( sal_uInt32 nPoly, const sal_uInt32* pPoints, if( (m_nLayout & SalLayoutFlags::BiDiRtl) || (pOutDev && pOutDev->IsRTLEnabled()) ) { // TODO: optimize, reduce new/delete calls - SalPoint **pPtAry2 = new SalPoint*[nPoly]; + std::unique_ptr<SalPoint*[]> pPtAry2( new SalPoint*[nPoly] ); sal_uLong i; for(i=0; i<nPoly; i++) { @@ -428,11 +428,10 @@ void SalGraphics::DrawPolyPolygon( sal_uInt32 nPoly, const sal_uInt32* pPoints, mirror( nPoints, pPtAry[i], pPtAry2[i], pOutDev ); } - drawPolyPolygon( nPoly, pPoints, const_cast<PCONSTSALPOINT*>(pPtAry2) ); + drawPolyPolygon( nPoly, pPoints, const_cast<PCONSTSALPOINT*>(pPtAry2.get()) ); for(i=0; i<nPoly; i++) delete [] pPtAry2[i]; - delete [] pPtAry2; } else drawPolyPolygon( nPoly, pPoints, pPtAry ); @@ -486,7 +485,7 @@ bool SalGraphics::DrawPolyPolygonBezier( sal_uInt32 i_nPoly, const sal_uInt32* i if( (m_nLayout & SalLayoutFlags::BiDiRtl) || (i_pOutDev && i_pOutDev->IsRTLEnabled()) ) { // TODO: optimize, reduce new/delete calls - SalPoint **pPtAry2 = new SalPoint*[i_nPoly]; + std::unique_ptr<SalPoint*[]> pPtAry2( new SalPoint*[i_nPoly] ); sal_uLong i; for(i=0; i<i_nPoly; i++) { @@ -495,11 +494,10 @@ bool SalGraphics::DrawPolyPolygonBezier( sal_uInt32 i_nPoly, const sal_uInt32* i mirror( nPoints, i_pPtAry[i], pPtAry2[i], i_pOutDev ); } - bRet = drawPolyPolygonBezier( i_nPoly, i_pPoints, const_cast<PCONSTSALPOINT const *>(pPtAry2), i_pFlgAry ); + bRet = drawPolyPolygonBezier( i_nPoly, i_pPoints, const_cast<PCONSTSALPOINT const *>(pPtAry2.get()), i_pFlgAry ); for(i=0; i<i_nPoly; i++) delete [] pPtAry2[i]; - delete [] pPtAry2; } else bRet = drawPolyPolygonBezier( i_nPoly, i_pPoints, i_pPtAry, i_pFlgAry ); |