diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-07-10 13:57:53 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-07-11 16:01:28 +0200 |
commit | 673347af7d37f6789855c17732c9980d91ec6240 (patch) | |
tree | 4447a73900c50db2f949755eca64a91ac2d9a385 /svx | |
parent | 0bc97adb82f14d6ec22f868422cbfe000afec402 (diff) |
loplugin:useuniqueptr in scaddins..svx
Change-Id: I309f98f6b820103a926e9fe94d67d0aff6eb6476
Reviewed-on: https://gerrit.libreoffice.org/39754
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'svx')
-rw-r--r-- | svx/inc/xpolyimp.hxx | 4 | ||||
-rw-r--r-- | svx/source/dialog/svxruler.cxx | 18 | ||||
-rw-r--r-- | svx/source/svdraw/svdattr.cxx | 2 | ||||
-rw-r--r-- | svx/source/xoutdev/_xpoly.cxx | 21 | ||||
-rw-r--r-- | svx/source/xoutdev/xpool.cxx | 4 |
5 files changed, 24 insertions, 25 deletions
diff --git a/svx/inc/xpolyimp.hxx b/svx/inc/xpolyimp.hxx index 35ead6c9a87a..02c9b08e1bef 100644 --- a/svx/inc/xpolyimp.hxx +++ b/svx/inc/xpolyimp.hxx @@ -21,6 +21,7 @@ #define INCLUDED_SVX_INC_XPOLYIMP_HXX #include <svx/xpoly.hxx> +#include <memory> #include <vector> class Point; @@ -29,7 +30,8 @@ class ImpXPolygon { public: Point* pPointAry; - PolyFlags* pFlagAry; + std::unique_ptr<PolyFlags[]> + pFlagAry; Point* pOldPointAry; bool bDeleteOldPoints; sal_uInt16 nSize; diff --git a/svx/source/dialog/svxruler.cxx b/svx/source/dialog/svxruler.cxx index 6c17a9c448c1..5beb625cb0a4 100644 --- a/svx/source/dialog/svxruler.cxx +++ b/svx/source/dialog/svxruler.cxx @@ -39,6 +39,7 @@ #include <svx/svdtrans.hxx> #include "rlrcitem.hxx" +#include <memory> #ifndef RULER_TAB_RTL #define RULER_TAB_RTL ((sal_uInt16)0x0010) @@ -115,8 +116,8 @@ void RulerDebugWindow::AddDebugText(const sal_Char* pDescription, const OUSt #endif struct SvxRuler_Impl { - sal_uInt16 *pPercBuf; - sal_uInt16 *pBlockBuf; + std::unique_ptr<sal_uInt16[]> pPercBuf; + std::unique_ptr<sal_uInt16[]> pBlockBuf; sal_uInt16 nPercSize; long nTotalDist; long lOldWinPos; @@ -152,7 +153,7 @@ struct SvxRuler_Impl { ~SvxRuler_Impl() { nPercSize = 0; nTotalDist = 0; - delete[] pPercBuf; delete[] pBlockBuf; pPercBuf = nullptr; + pPercBuf = nullptr; delete pTextRTLItem; } void SetPercSize(sal_uInt16 nSize); @@ -183,14 +184,13 @@ void SvxRuler_Impl::SetPercSize(sal_uInt16 nSize) { if(nSize > nPercSize) { - delete[] pPercBuf; - delete[] pBlockBuf; - pPercBuf = new sal_uInt16[nPercSize = nSize]; - pBlockBuf = new sal_uInt16[nPercSize = nSize]; + nPercSize = nSize; + pPercBuf.reset( new sal_uInt16[nPercSize] ); + pBlockBuf.reset( new sal_uInt16[nPercSize] ); } size_t nSize2 = sizeof(sal_uInt16) * nPercSize; - memset(pPercBuf, 0, nSize2); - memset(pBlockBuf, 0, nSize2); + memset(pPercBuf.get(), 0, nSize2); + memset(pBlockBuf.get(), 0, nSize2); } // Constructor of the ruler diff --git a/svx/source/svdraw/svdattr.cxx b/svx/source/svdraw/svdattr.cxx index ebac16e576af..46ae6858ec01 100644 --- a/svx/source/svdraw/svdattr.cxx +++ b/svx/source/svdraw/svdattr.cxx @@ -339,7 +339,7 @@ SdrItemPool::SdrItemPool( // it's my own creation level, set Defaults and ItemInfos SetDefaults(mpLocalPoolDefaults); - SetItemInfos(mpLocalItemInfos); + SetItemInfos(mpLocalItemInfos.get()); } // copy ctor, so that static defaults are cloned diff --git a/svx/source/xoutdev/_xpoly.cxx b/svx/source/xoutdev/_xpoly.cxx index 39d8cfc6aa14..f8d6b12f48f7 100644 --- a/svx/source/xoutdev/_xpoly.cxx +++ b/svx/source/xoutdev/_xpoly.cxx @@ -62,13 +62,12 @@ ImpXPolygon::ImpXPolygon( const ImpXPolygon& rImpXPoly ) // copy nPoints = rImpXPoly.nPoints; memcpy( pPointAry, rImpXPoly.pPointAry, nSize*sizeof( Point ) ); - memcpy( pFlagAry, rImpXPoly.pFlagAry, nSize ); + memcpy( pFlagAry.get(), rImpXPoly.pFlagAry.get(), nSize ); } ImpXPolygon::~ImpXPolygon() { delete[] reinterpret_cast<char*>(pPointAry); - delete[] pFlagAry; if ( bDeleteOldPoints ) { delete[] reinterpret_cast<char*>(pOldPointAry); @@ -80,8 +79,8 @@ bool ImpXPolygon::operator==(const ImpXPolygon& rImpXPoly) const { return nPoints==rImpXPoly.nPoints && (nPoints==0 || - (memcmp(pPointAry,rImpXPoly.pPointAry,nPoints*sizeof(Point))==0 && - memcmp(pFlagAry,rImpXPoly.pFlagAry,nPoints)==0)); + (memcmp(pPointAry, rImpXPoly.pPointAry, nPoints*sizeof(Point))==0 && + memcmp(pFlagAry.get(), rImpXPoly.pFlagAry.get(), nPoints)==0)); } /** Change polygon size @@ -97,7 +96,7 @@ void ImpXPolygon::Resize( sal_uInt16 nNewSize, bool bDeletePoints ) if( nNewSize == nSize ) return; - PolyFlags* pOldFlagAry = pFlagAry; + PolyFlags* pOldFlagAry = pFlagAry.get(); sal_uInt16 nOldSize = nSize; CheckPointDelete(); @@ -116,8 +115,8 @@ void ImpXPolygon::Resize( sal_uInt16 nNewSize, bool bDeletePoints ) memset( pPointAry, 0, nSize*sizeof( Point ) ); // create flag array - pFlagAry = new PolyFlags[ nSize ]; - memset( pFlagAry, 0, nSize ); + pFlagAry.reset( new PolyFlags[ nSize ] ); + memset( pFlagAry.get(), 0, nSize ); // copy if needed if( nOldSize ) @@ -125,12 +124,12 @@ void ImpXPolygon::Resize( sal_uInt16 nNewSize, bool bDeletePoints ) if( nOldSize < nSize ) { memcpy( pPointAry, pOldPointAry, nOldSize*sizeof( Point ) ); - memcpy( pFlagAry, pOldFlagAry, nOldSize ); + memcpy( pFlagAry.get(), pOldFlagAry, nOldSize ); } else { memcpy( pPointAry, pOldPointAry, nSize*sizeof( Point ) ); - memcpy( pFlagAry, pOldFlagAry, nSize ); + memcpy( pFlagAry.get(), pOldFlagAry, nSize ); // adjust number of valid points if( nPoints > nSize ) @@ -383,7 +382,7 @@ void XPolygon::Insert( sal_uInt16 nPos, const XPolygon& rXPoly ) rXPoly.pImpXPolygon->pPointAry, nPoints*sizeof( Point ) ); memcpy( &(pImpXPolygon->pFlagAry[nPos]), - rXPoly.pImpXPolygon->pFlagAry, + rXPoly.pImpXPolygon->pFlagAry.get(), nPoints ); } @@ -835,7 +834,7 @@ basegfx::B2DPolygon XPolygon::getB2DPolygon() const // #i74631# use tools Polygon class for conversion to not have the code doubled // here. This needs one more conversion but avoids different convertors in // the long run - const tools::Polygon aSource(GetPointCount(), pImpXPolygon->pPointAry, pImpXPolygon->pFlagAry); + const tools::Polygon aSource(GetPointCount(), pImpXPolygon->pPointAry, pImpXPolygon->pFlagAry.get()); return aSource.getB2DPolygon(); } diff --git a/svx/source/xoutdev/xpool.cxx b/svx/source/xoutdev/xpool.cxx index 0146afe75120..367e07aaf18d 100644 --- a/svx/source/xoutdev/xpool.cxx +++ b/svx/source/xoutdev/xpool.cxx @@ -161,7 +161,7 @@ XOutdevItemPool::XOutdevItemPool(SfxItemPool* _pMaster, bool bLoadRefCounts) if(XATTR_START == GetFirstWhich() && XATTR_END == GetLastWhich()) { SetDefaults(mpLocalPoolDefaults); - SetItemInfos(mpLocalItemInfos); + SetItemInfos(mpLocalItemInfos.get()); } } @@ -183,8 +183,6 @@ XOutdevItemPool::~XOutdevItemPool() Delete(); // release and delete static pool default items ReleaseDefaults(true); - - delete[] mpLocalItemInfos; } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |