Kaydet (Commit) 91af898b authored tarafından Noel Grandin's avatar Noel Grandin

loplugin:useuniqueptr in Sane

Change-Id: I06e9423e667ee87d767bbc17e62798ae0586e975
Reviewed-on: https://gerrit.libreoffice.org/53877Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst a36d6724
......@@ -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;
......
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment