summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2018-04-23 15:19:49 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2018-04-25 09:30:44 +0200
commitef46d846fdedd9e94f7150afda810d12acce8c16 (patch)
tree63303a3fdf13a448ec61101189a0a80cda22d930 /vcl
parent7a67d7a7c10aad2bbc5dc3d0048259a8b80970cb (diff)
loplugin:useuniqueptr in PPDDecompressStream
Change-Id: Idad3c18c57e4ae4121505a0bd9761f8569685e33 Reviewed-on: https://gerrit.libreoffice.org/53358 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/unx/generic/printer/ppdparser.cxx20
1 files changed, 8 insertions, 12 deletions
diff --git a/vcl/unx/generic/printer/ppdparser.cxx b/vcl/unx/generic/printer/ppdparser.cxx
index a6109af7f289..fc58bc3464b6 100644
--- a/vcl/unx/generic/printer/ppdparser.cxx
+++ b/vcl/unx/generic/printer/ppdparser.cxx
@@ -259,8 +259,8 @@ private:
PPDDecompressStream(const PPDDecompressStream&) = delete;
PPDDecompressStream& operator=(const PPDDecompressStream&) = delete;
- SvFileStream* mpFileStream;
- SvMemoryStream* mpMemStream;
+ std::unique_ptr<SvFileStream> mpFileStream;
+ std::unique_ptr<SvMemoryStream> mpMemStream;
OUString maFileName;
public:
@@ -291,7 +291,7 @@ void PPDDecompressStream::Open( const OUString& i_rFile )
{
Close();
- mpFileStream = new SvFileStream( i_rFile, StreamMode::READ );
+ mpFileStream.reset( new SvFileStream( i_rFile, StreamMode::READ ) );
maFileName = mpFileStream->GetFileName();
if( ! mpFileStream->IsOpen() )
@@ -309,7 +309,7 @@ void PPDDecompressStream::Open( const OUString& i_rFile )
&& static_cast<unsigned char>(aLine[1]) == 0x8b /* check for gzip */ )
{
// so let's try to decompress the stream
- mpMemStream = new SvMemoryStream( 4096, 4096 );
+ mpMemStream.reset( new SvMemoryStream( 4096, 4096 ) );
ZCodec aCodec;
aCodec.BeginCompression( ZCODEC_DEFAULT_COMPRESSION, false, true );
long nComp = aCodec.Decompress( *mpFileStream, *mpMemStream );
@@ -317,15 +317,13 @@ void PPDDecompressStream::Open( const OUString& i_rFile )
if( nComp < 0 )
{
// decompression failed, must be an uncompressed stream after all
- delete mpMemStream;
- mpMemStream = nullptr;
+ mpMemStream.reset();
mpFileStream->Seek( 0 );
}
else
{
// compression successful, can get rid of file stream
- delete mpFileStream;
- mpFileStream = nullptr;
+ mpFileStream.reset();
mpMemStream->Seek( 0 );
}
}
@@ -333,10 +331,8 @@ void PPDDecompressStream::Open( const OUString& i_rFile )
void PPDDecompressStream::Close()
{
- delete mpMemStream;
- mpMemStream = nullptr;
- delete mpFileStream;
- mpFileStream = nullptr;
+ mpMemStream.reset();
+ mpFileStream.reset();
}
bool PPDDecompressStream::IsOpen() const