summaryrefslogtreecommitdiff
path: root/xmloff
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 /xmloff
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 'xmloff')
-rw-r--r--xmloff/source/draw/EnhancedCustomShapeToken.cxx6
1 files changed, 3 insertions, 3 deletions
diff --git a/xmloff/source/draw/EnhancedCustomShapeToken.cxx b/xmloff/source/draw/EnhancedCustomShapeToken.cxx
index 9bcdb8f1aa65..076ae2728fbd 100644
--- a/xmloff/source/draw/EnhancedCustomShapeToken.cxx
+++ b/xmloff/source/draw/EnhancedCustomShapeToken.cxx
@@ -20,6 +20,7 @@
#include "EnhancedCustomShapeToken.hxx"
#include <osl/mutex.hxx>
#include <unordered_map>
+#include <memory>
#include <string.h>
namespace xmloff { namespace EnhancedCustomShapeToken {
@@ -183,12 +184,11 @@ EnhancedCustomShapeTokenEnum EASGet( const OUString& rShapeType )
}
EnhancedCustomShapeTokenEnum eRetValue = EAS_NotFound;
int i, nLen = rShapeType.getLength();
- char* pBuf = new char[ nLen + 1 ];
+ std::unique_ptr<char[]> pBuf(new char[ nLen + 1 ]);
for ( i = 0; i < nLen; i++ )
pBuf[ i ] = (char)rShapeType[ i ];
pBuf[ i ] = 0;
- TypeNameHashMap::iterator aHashIter( pHashMap->find( pBuf ) );
- delete[] pBuf;
+ TypeNameHashMap::iterator aHashIter( pHashMap->find( pBuf.get() ) );
if ( aHashIter != pHashMap->end() )
eRetValue = (*aHashIter).second;
return eRetValue;