diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-04-06 09:46:06 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-04-06 09:22:46 +0000 |
commit | aa09b0c27a6d925da428d6267daadc7338829869 (patch) | |
tree | b0fa576ff64820061d9fb876bebacd23e58ddc56 /basegfx/source/matrix | |
parent | 0c82dff153d92150729815b919854a9a350aa031 (diff) |
loplugin:useuniqueptr extend to catch more localvar cases
i.e. where the code looks like
{
foo * p = new foo;
...
delete p;
return ...;
}
Change-Id: Id5f2e55d0363fc62c72535a23faeaaf1f0ac6aee
Reviewed-on: https://gerrit.libreoffice.org/36190
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'basegfx/source/matrix')
-rw-r--r-- | basegfx/source/matrix/b2dhommatrix.cxx | 10 | ||||
-rw-r--r-- | basegfx/source/matrix/b3dhommatrix.cxx | 10 |
2 files changed, 8 insertions, 12 deletions
diff --git a/basegfx/source/matrix/b2dhommatrix.cxx b/basegfx/source/matrix/b2dhommatrix.cxx index 2dce96fb2379..7e228ca48dea 100644 --- a/basegfx/source/matrix/b2dhommatrix.cxx +++ b/basegfx/source/matrix/b2dhommatrix.cxx @@ -24,6 +24,7 @@ #include <basegfx/tuple/b2dtuple.hxx> #include <basegfx/vector/b2dvector.hxx> #include <basegfx/matrix/b2dhommatrixtools.hxx> +#include <memory> namespace basegfx { @@ -123,18 +124,15 @@ namespace basegfx bool B2DHomMatrix::invert() { Impl2DHomMatrix aWork(*mpImpl); - sal_uInt16* pIndex = new sal_uInt16[Impl2DHomMatrix_Base::getEdgeLength()]; + std::unique_ptr<sal_uInt16[]> pIndex( new sal_uInt16[Impl2DHomMatrix_Base::getEdgeLength()] ); sal_Int16 nParity; - if(aWork.ludcmp(pIndex, nParity)) + if(aWork.ludcmp(pIndex.get(), nParity)) { - mpImpl->doInvert(aWork, pIndex); - delete[] pIndex; - + mpImpl->doInvert(aWork, pIndex.get()); return true; } - delete[] pIndex; return false; } diff --git a/basegfx/source/matrix/b3dhommatrix.cxx b/basegfx/source/matrix/b3dhommatrix.cxx index e0c049c5bf55..919a00c9fb50 100644 --- a/basegfx/source/matrix/b3dhommatrix.cxx +++ b/basegfx/source/matrix/b3dhommatrix.cxx @@ -21,6 +21,7 @@ #include <basegfx/matrix/b3dhommatrix.hxx> #include <hommatrixtemplate.hxx> #include <basegfx/vector/b3dvector.hxx> +#include <memory> namespace basegfx { @@ -94,18 +95,15 @@ namespace basegfx bool B3DHomMatrix::invert() { Impl3DHomMatrix aWork(*mpImpl); - sal_uInt16* pIndex = new sal_uInt16[Impl3DHomMatrix_Base::getEdgeLength()]; + std::unique_ptr<sal_uInt16[]> pIndex( new sal_uInt16[Impl3DHomMatrix_Base::getEdgeLength()] ); sal_Int16 nParity; - if(aWork.ludcmp(pIndex, nParity)) + if(aWork.ludcmp(pIndex.get(), nParity)) { - mpImpl->doInvert(aWork, pIndex); - delete[] pIndex; - + mpImpl->doInvert(aWork, pIndex.get()); return true; } - delete[] pIndex; return false; } |