summaryrefslogtreecommitdiff
path: root/scaddins
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2015-11-10 13:36:34 +0200
committerNoel Grandin <noelgrandin@gmail.com>2015-11-11 07:16:20 +0000
commitdb17d3c17c40d6b0e92392cf3c6e343d1d17b771 (patch)
tree9d562fcf764e7717df9585ef0e735a12ea4aaa16 /scaddins
parent2ce9e4be4a438203382cb9cca824ce3e90647f3a (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 'scaddins')
-rw-r--r--scaddins/source/analysis/analysishelper.cxx9
1 files changed, 4 insertions, 5 deletions
diff --git a/scaddins/source/analysis/analysishelper.cxx b/scaddins/source/analysis/analysishelper.cxx
index 35aa32b13e28..b820606c399f 100644
--- a/scaddins/source/analysis/analysishelper.cxx
+++ b/scaddins/source/analysis/analysishelper.cxx
@@ -26,6 +26,7 @@
#include <rtl/math.hxx>
#include <sal/macros.h>
#include <algorithm>
+#include <memory>
#include "analysishelper.hxx"
#include "analysis.hrc"
@@ -746,14 +747,12 @@ OUString ConvertFromDec( double fNum, double fMin, double fMax, sal_uInt16 nBase
else if( ( bNeg && nLen < nMaxPlaces ) || ( !bNeg && nLen < nPlaces ) )
{
sal_Int32 nLeft = nPlaces - nLen;
- sal_Char* p = new sal_Char[ nLeft + 1 ];
- memset( p, bNeg? GetMaxChar( nBase ) : '0', nLeft );
+ std::unique_ptr<sal_Char[]> p( new sal_Char[ nLeft + 1 ] );
+ memset( p.get(), bNeg ? GetMaxChar( nBase ) : '0', nLeft );
p[ nLeft ] = 0x00;
- OUString aTmp( p, nLeft, RTL_TEXTENCODING_MS_1252 );
+ OUString aTmp( p.get(), nLeft, RTL_TEXTENCODING_MS_1252 );
aTmp += aRet;
aRet = aTmp;
-
- delete[] p;
}
}