summaryrefslogtreecommitdiff
path: root/tools
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 /tools
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 'tools')
-rw-r--r--tools/source/inet/inetmime.cxx8
1 files changed, 4 insertions, 4 deletions
diff --git a/tools/source/inet/inetmime.cxx b/tools/source/inet/inetmime.cxx
index 6a817ee967c1..d4004c79c544 100644
--- a/tools/source/inet/inetmime.cxx
+++ b/tools/source/inet/inetmime.cxx
@@ -19,6 +19,7 @@
#include <cstddef>
#include <limits>
+#include <memory>
#include <osl/diagnose.h>
#include <rtl/alloc.h>
@@ -537,11 +538,10 @@ void appendISO88591(OUString & rText, sal_Char const * pBegin,
sal_Char const * pEnd)
{
sal_Int32 nLength = pEnd - pBegin;
- sal_Unicode * pBuffer = new sal_Unicode[nLength];
- for (sal_Unicode * p = pBuffer; pBegin != pEnd;)
+ std::unique_ptr<sal_Unicode[]> pBuffer(new sal_Unicode[nLength]);
+ for (sal_Unicode * p = pBuffer.get(); pBegin != pEnd;)
*p++ = static_cast<unsigned char>(*pBegin++);
- rText += OUString(pBuffer, nLength);
- delete[] pBuffer;
+ rText += OUString(pBuffer.get(), nLength);
}
// INetMIMECharsetList_Impl