summaryrefslogtreecommitdiff
path: root/extensions
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2018-10-23 08:23:32 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2018-10-23 10:02:32 +0200
commit86cce1343ca5ed85eece1c9d065f9f861d57f9d9 (patch)
tree6c6ad9d0d5166b08ad7c2635bd6f4da78630a55b /extensions
parenta8a461b2fba27f1a729e2b9b28426286617892a9 (diff)
loplugin:useuniqueptr in Sane::Start
Change-Id: Iea78ab60d294e1cf29c5ad02a540880a42762398 Reviewed-on: https://gerrit.libreoffice.org/62213 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'extensions')
-rw-r--r--extensions/source/scanner/sane.cxx16
1 files changed, 8 insertions, 8 deletions
diff --git a/extensions/source/scanner/sane.cxx b/extensions/source/scanner/sane.cxx
index 0adeb593d695..4cc31667cc80 100644
--- a/extensions/source/scanner/sane.cxx
+++ b/extensions/source/scanner/sane.cxx
@@ -570,7 +570,7 @@ bool Sane::Start( BitmapTransporter& rBitmap )
if( ( nOption = GetOptionByName( "resolution" ) ) != -1 )
(void)GetOptionValue( nOption, fResl );
- sal_uInt8* pBuffer = nullptr;
+ std::unique_ptr<sal_uInt8[]> pBuffer;
SANE_Status nStatus = SANE_STATUS_GOOD;
@@ -636,7 +636,7 @@ bool Sane::Start( BitmapTransporter& rBitmap )
#endif
if( ! pBuffer )
{
- pBuffer = new sal_uInt8[ BYTE_BUFFER_SIZE < 4*aParams.bytes_per_line ? 4*aParams.bytes_per_line : BYTE_BUFFER_SIZE ];
+ pBuffer.reset(new sal_uInt8[ BYTE_BUFFER_SIZE < 4*aParams.bytes_per_line ? 4*aParams.bytes_per_line : BYTE_BUFFER_SIZE ]);
}
if( aParams.last_frame )
@@ -710,12 +710,12 @@ bool Sane::Start( BitmapTransporter& rBitmap )
fprintf( stderr, "Timeout on sane_read descriptor\n" );
}
nLen = 0;
- nStatus = p_read( maHandle, pBuffer, BYTE_BUFFER_SIZE, &nLen );
+ nStatus = p_read( maHandle, pBuffer.get(), BYTE_BUFFER_SIZE, &nLen );
CheckConsistency( "sane_read" );
if( nLen && ( nStatus == SANE_STATUS_GOOD ||
nStatus == SANE_STATUS_EOF ) )
{
- bSuccess = (static_cast<size_t>(nLen) == fwrite( pBuffer, 1, nLen, pFrame ));
+ bSuccess = (static_cast<size_t>(nLen) == fwrite( pBuffer.get(), 1, nLen, pFrame ));
if (!bSuccess)
break;
}
@@ -793,13 +793,13 @@ bool Sane::Start( BitmapTransporter& rBitmap )
( eType == FrameStyle_Gray && aParams.depth == 8 )
)
{
- SANE_Int items_read = fread( pBuffer, 1, aParams.bytes_per_line, pFrame );
+ SANE_Int items_read = fread( pBuffer.get(), 1, aParams.bytes_per_line, pFrame );
if (items_read != aParams.bytes_per_line)
{
SAL_WARN( "extensions.scanner", "short read, padding with zeros" );
- memset(pBuffer + items_read, 0, aParams.bytes_per_line - items_read);
+ memset(pBuffer.get() + items_read, 0, aParams.bytes_per_line - items_read);
}
- aConverter.WriteBytes(pBuffer, aParams.bytes_per_line);
+ aConverter.WriteBytes(pBuffer.get(), aParams.bytes_per_line);
}
else if( eType == FrameStyle_Gray )
{
@@ -875,7 +875,7 @@ bool Sane::Start( BitmapTransporter& rBitmap )
p_cancel( maHandle );
CheckConsistency( "sane_cancel" );
}
- delete [] pBuffer;
+ pBuffer.reset();
ReloadOptions();