diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-04-06 09:46:06 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-04-06 09:22:46 +0000 |
commit | aa09b0c27a6d925da428d6267daadc7338829869 (patch) | |
tree | b0fa576ff64820061d9fb876bebacd23e58ddc56 /tools | |
parent | 0c82dff153d92150729815b919854a9a350aa031 (diff) |
loplugin:useuniqueptr extend to catch more localvar cases
i.e. where the code looks like
{
foo * p = new foo;
...
delete p;
return ...;
}
Change-Id: Id5f2e55d0363fc62c72535a23faeaaf1f0ac6aee
Reviewed-on: https://gerrit.libreoffice.org/36190
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/source/stream/stream.cxx | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/tools/source/stream/stream.cxx b/tools/source/stream/stream.cxx index d2de88e44d3e..d30c5e0bf125 100644 --- a/tools/source/stream/stream.cxx +++ b/tools/source/stream/stream.cxx @@ -1003,15 +1003,14 @@ SvStream& SvStream::ReadDouble(double& r) SvStream& SvStream::ReadStream( SvStream& rStream ) { const sal_uInt32 cBufLen = 0x8000; - char* pBuf = new char[ cBufLen ]; + std::unique_ptr<char[]> pBuf( new char[ cBufLen ] ); sal_uInt32 nCount; do { - nCount = ReadBytes( pBuf, cBufLen ); - rStream.WriteBytes( pBuf, nCount ); + nCount = ReadBytes( pBuf.get(), cBufLen ); + rStream.WriteBytes( pBuf.get(), nCount ); } while( nCount == cBufLen ); - delete[] pBuf; return *this; } @@ -1166,14 +1165,13 @@ SvStream& SvStream::WriteCharPtr( const char* pBuf ) SvStream& SvStream::WriteStream( SvStream& rStream ) { const sal_uInt32 cBufLen = 0x8000; - char* pBuf = new char[ cBufLen ]; + std::unique_ptr<char[]> pBuf( new char[ cBufLen ] ); sal_uInt32 nCount; do { - nCount = rStream.ReadBytes( pBuf, cBufLen ); - WriteBytes( pBuf, nCount ); + nCount = rStream.ReadBytes( pBuf.get(), cBufLen ); + WriteBytes( pBuf.get(), nCount ); } while( nCount == cBufLen ); - delete[] pBuf; return *this; } |