summaryrefslogtreecommitdiff
path: root/extensions
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2018-05-04 14:02:49 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2018-05-07 08:33:26 +0200
commit91af898b2a9193219bd28aa64296eaf0e145beb6 (patch)
tree414070ce629728f8f119080d92ed31b2e7a905d7 /extensions
parenta36d67240c303101fb6a56e40ff46aa1023089f3 (diff)
loplugin:useuniqueptr in Sane
Change-Id: I06e9423e667ee87d767bbc17e62798ae0586e975 Reviewed-on: https://gerrit.libreoffice.org/53877 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'extensions')
-rw-r--r--extensions/source/scanner/sane.cxx11
-rw-r--r--extensions/source/scanner/sane.hxx2
2 files changed, 5 insertions, 8 deletions
diff --git a/extensions/source/scanner/sane.cxx b/extensions/source/scanner/sane.cxx
index 4bd94f30d83e..90eb652282b2 100644
--- a/extensions/source/scanner/sane.cxx
+++ b/extensions/source/scanner/sane.cxx
@@ -273,9 +273,7 @@ void Sane::ReloadOptions()
mnOptions = pOptions[ 0 ];
if( static_cast<size_t>(pZero->size) > sizeof( SANE_Word ) )
fprintf( stderr, "driver returned numer of options with larger size tha SANE_Word !!!\n" );
- if( mppOptions )
- delete [] mppOptions;
- mppOptions = new const SANE_Option_Descriptor*[ mnOptions ];
+ mppOptions.reset(new const SANE_Option_Descriptor*[ mnOptions ]);
mppOptions[ 0 ] = pZero;
for( int i = 1; i < mnOptions; i++ )
mppOptions[ i ] = p_get_option_descriptor( maHandle, i );
@@ -323,8 +321,7 @@ void Sane::Close()
if( maHandle )
{
p_close( maHandle );
- delete [] mppOptions;
- mppOptions = nullptr;
+ mppOptions.reset();
maHandle = nullptr;
mnDevice = -1;
}
@@ -513,7 +510,7 @@ bool Sane::CheckConsistency( const char* pMes, bool bInit )
if( bInit )
{
- pDescArray = mppOptions;
+ pDescArray = mppOptions.get();
if( mppOptions )
pZero = mppOptions[0];
return true;
@@ -521,7 +518,7 @@ bool Sane::CheckConsistency( const char* pMes, bool bInit )
bool bConsistent = true;
- if( pDescArray != mppOptions )
+ if( pDescArray != mppOptions.get() )
bConsistent = false;
if( pZero != mppOptions[0] )
bConsistent = false;
diff --git a/extensions/source/scanner/sane.hxx b/extensions/source/scanner/sane.hxx
index ae8b6861eff7..7145ab133b27 100644
--- a/extensions/source/scanner/sane.hxx
+++ b/extensions/source/scanner/sane.hxx
@@ -80,7 +80,7 @@ private:
static SANE_Device** ppDevices;
static int nDevices;
- const SANE_Option_Descriptor** mppOptions;
+ std::unique_ptr<const SANE_Option_Descriptor*[]> mppOptions;
int mnOptions;
int mnDevice;
SANE_Handle maHandle;