diff options
author | Noel Grandin <noel@peralex.com> | 2015-11-10 13:36:34 +0200 |
---|---|---|
committer | Noel Grandin <noelgrandin@gmail.com> | 2015-11-11 07:16:20 +0000 |
commit | db17d3c17c40d6b0e92392cf3c6e343d1d17b771 (patch) | |
tree | 9d562fcf764e7717df9585ef0e735a12ea4aaa16 /extensions | |
parent | 2ce9e4be4a438203382cb9cca824ce3e90647f3a (diff) |
new loplugin: memoryvar
detect when we can convert a new/delete sequence on a local variable to
use std::unique_ptr
Change-Id: Iecae4e4197eccdfacfce2eed39aa4a69e4a660bc
Reviewed-on: https://gerrit.libreoffice.org/19884
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
Diffstat (limited to 'extensions')
-rw-r--r-- | extensions/source/plugin/unx/npnapi.cxx | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/extensions/source/plugin/unx/npnapi.cxx b/extensions/source/plugin/unx/npnapi.cxx index 3a7eca7b04a5..7f70a5e39ea7 100644 --- a/extensions/source/plugin/unx/npnapi.cxx +++ b/extensions/source/plugin/unx/npnapi.cxx @@ -44,6 +44,7 @@ #include <config_vclplug.h> #include <npwrap.hxx> +#include <memory> extern PluginConnector* pConnector; extern XtAppContext app_context; @@ -270,7 +271,7 @@ static NPError l_NPN_RequestRead( NPStream* stream, NPByteRange* rangeList ) pRange = pRange->next; } - sal_uInt32* pArray = new sal_uInt32[ 2 * nRanges ]; + std::unique_ptr<sal_uInt32[]> pArray(new sal_uInt32[ 2 * nRanges ]); pRange = rangeList; sal_uInt32 n = 0; while( pRange ) @@ -285,17 +286,15 @@ static NPError l_NPN_RequestRead( NPStream* stream, NPByteRange* rangeList ) Transact( eNPN_RequestRead, &nFileID, sizeof( nFileID ), &nRanges, sizeof( nRanges ), - pArray, sizeof( sal_uInt32 ) * 2 * nRanges, + pArray.get(), sizeof( sal_uInt32 ) * 2 * nRanges, NULL ); if( ! pMes ) { - delete[] pArray; return NPERR_GENERIC_ERROR; } NPError aRet = PluginConnector::GetNPError( pMes ); - delete [] pArray; delete pMes; return aRet; } |