summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2017-01-31 14:46:38 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2017-02-01 12:15:22 +0000
commit2489000d3fd66319a8355fd4e37cfdfda47296d0 (patch)
treecaad79e7b5bec3863604b20190b682c0d73d2b25 /tools
parent595848c85acc2609fcc48a40c7a9f216a2722cd8 (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 Change-Id: I3a7a094da543debdcd2374737c2ecff91d644625 Reviewed-on: https://gerrit.libreoffice.org/33749 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'tools')
-rw-r--r--tools/source/generic/poly.cxx3
-rw-r--r--tools/source/inet/inetmime.cxx7
2 files changed, 4 insertions, 6 deletions
diff --git a/tools/source/generic/poly.cxx b/tools/source/generic/poly.cxx
index 945c0306e73b..b0f068370d27 100644
--- a/tools/source/generic/poly.cxx
+++ b/tools/source/generic/poly.cxx
@@ -599,7 +599,7 @@ Polygon::Polygon( const Rectangle& rRect, sal_uInt32 nHorzRound, sal_uInt32 nVer
const Point aTR( aRect.Right() - nHorzRound, aRect.Top() + nVertRound );
const Point aBR( aRect.Right() - nHorzRound, aRect.Bottom() - nVertRound );
const Point aBL( aRect.Left() + nHorzRound, aRect.Bottom() - nVertRound );
- tools::Polygon* pEllipsePoly = new tools::Polygon( Point(), nHorzRound, nVertRound );
+ std::unique_ptr<tools::Polygon> pEllipsePoly( new tools::Polygon( Point(), nHorzRound, nVertRound ) );
sal_uInt16 i, nEnd, nSize4 = pEllipsePoly->GetSize() >> 2;
mpImplPolygon = new ImplPolygon( pEllipsePoly->GetSize() + 1 );
@@ -620,7 +620,6 @@ Polygon::Polygon( const Rectangle& rRect, sal_uInt32 nHorzRound, sal_uInt32 nVer
( pDstAry[ i ] = pSrcAry[ i ] ) += aBR;
pDstAry[ nEnd ] = pDstAry[ 0 ];
- delete pEllipsePoly;
}
}
}
diff --git a/tools/source/inet/inetmime.cxx b/tools/source/inet/inetmime.cxx
index 05ae7cb91c15..0eb29f55d072 100644
--- a/tools/source/inet/inetmime.cxx
+++ b/tools/source/inet/inetmime.cxx
@@ -2725,16 +2725,15 @@ void INetMIMEOutputSink::writeSequence(const sal_Unicode * pBegin,
assert(pBegin && pBegin <= pEnd &&
"INetMIMEOutputSink::writeSequence(): Bad sequence");
- sal_Char * pBufferBegin = new sal_Char[pEnd - pBegin];
- sal_Char * pBufferEnd = pBufferBegin;
+ std::unique_ptr<sal_Char[]> pBufferBegin( new sal_Char[pEnd - pBegin] );
+ sal_Char * pBufferEnd = pBufferBegin.get();
while (pBegin != pEnd)
{
DBG_ASSERT(*pBegin < 256,
"INetMIMEOutputSink::writeSequence(): Bad octet");
*pBufferEnd++ = sal_Char(*pBegin++);
}
- writeSequence(pBufferBegin, pBufferEnd);
- delete[] pBufferBegin;
+ writeSequence(pBufferBegin.get(), pBufferEnd);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */