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 /testtools | |
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 'testtools')
-rw-r--r-- | testtools/source/bridgetest/bridgetest.cxx | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/testtools/source/bridgetest/bridgetest.cxx b/testtools/source/bridgetest/bridgetest.cxx index 701415844a5e..961cd9de1b1c 100644 --- a/testtools/source/bridgetest/bridgetest.cxx +++ b/testtools/source/bridgetest/bridgetest.cxx @@ -51,6 +51,7 @@ #include "currentcontextchecker.hxx" #include "multi.hxx" +#include <memory> using namespace osl; using namespace cppu; @@ -1043,8 +1044,8 @@ uno_Sequence* cloneSequence(const uno_Sequence* val, const Type& type) reinterpret_cast<typelib_IndirectTypeDescription*>(pTdRaw); typelib_TypeDescription* pTdElem = pIndirectTd->pType->pType; - sal_Int8* buf = new sal_Int8[pTdElem->nSize * val->nElements]; - sal_Int8* pBufCur = buf; + std::unique_ptr<sal_Int8[]> buf(new sal_Int8[pTdElem->nSize * val->nElements]); + sal_Int8* pBufCur = buf.get(); uno_Sequence* retSeq = nullptr; switch (pTdElem->eTypeClass) @@ -1070,7 +1071,6 @@ uno_Sequence* cloneSequence(const uno_Sequence* val, const Type& type) val->nElements, reinterpret_cast< uno_AcquireFunc >(cpp_acquire)); break; } - delete[] buf; return retSeq; } |