diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-01-31 14:46:38 +0200 |
---|---|---|
committer | Ashod Nakashian <ashod.nakashian@collabora.co.uk> | 2017-11-28 00:12:51 -0500 |
commit | e540ccfb5eb43bd4a3d6920074dce8436720ba8e (patch) | |
tree | fb8b1d7a30ab8de2cf34e42f62e00112d7d62301 /sc | |
parent | bf8fe9eaa36a9f8fc407ddbb2e7b561e5f9594c5 (diff) |
loplugin:useuniqueptr extend to check local vars
just the simple and obvious case for now, of a local var being allocated
and deleted inside a single local block, and the delete happening at the
end of the block
Reviewed-on: https://gerrit.libreoffice.org/33749
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
(cherry picked from commit 2489000d3fd66319a8355fd4e37cfdfda47296d0)
Change-Id: I3a7a094da543debdcd2374737c2ecff91d644625
Diffstat (limited to 'sc')
-rw-r--r-- | sc/source/core/tool/chartpos.cxx | 3 | ||||
-rw-r--r-- | sc/source/core/tool/rangeutl.cxx | 8 | ||||
-rw-r--r-- | sc/source/filter/rtf/eeimpars.cxx | 7 | ||||
-rw-r--r-- | sc/source/ui/view/formatsh.cxx | 3 |
4 files changed, 7 insertions, 14 deletions
diff --git a/sc/source/core/tool/chartpos.cxx b/sc/source/core/tool/chartpos.cxx index ad16dcfe472d..f4bd0c8c5615 100644 --- a/sc/source/core/tool/chartpos.cxx +++ b/sc/source/core/tool/chartpos.cxx @@ -358,7 +358,7 @@ void ScChartPositioner::CreatePositionMap() GlueState(); const bool bNoGlue = (eGlue == ScChartGlue::NONE); - ColumnMap* pCols = new ColumnMap; + std::unique_ptr<ColumnMap> pCols( new ColumnMap ); SCROW nNoGlueRow = 0; for ( size_t i = 0, nRanges = aRangeListRef->size(); i < nRanges; ++i ) { @@ -464,7 +464,6 @@ void ScChartPositioner::CreatePositionMap() { // Only delete tables, not the ScAddress*! delete it->second; } - delete pCols; } void ScChartPositioner::InvalidateGlue() diff --git a/sc/source/core/tool/rangeutl.cxx b/sc/source/core/tool/rangeutl.cxx index 2ea7a8642b9b..2dbe8107fae9 100644 --- a/sc/source/core/tool/rangeutl.cxx +++ b/sc/source/core/tool/rangeutl.cxx @@ -539,20 +539,16 @@ bool ScRangeStringConverter::GetRangeListFromString( sal_Int32 nOffset = 0; while( nOffset >= 0 ) { - ScRange* pRange = new ScRange; + std::unique_ptr<ScRange> pRange( new ScRange ); if ( GetRangeFromString( *pRange, rRangeListStr, pDocument, eConv, nOffset, cSeparator, cQuote ) && (nOffset >= 0) ) { - rRangeList.push_back( pRange ); - pRange = nullptr; + rRangeList.push_back( pRange.release() ); } else if (nOffset > -1) bRet = false; - //if ownership transferred to rRangeList pRange was NULLed, otherwwise - //delete it - delete pRange; } return bRet; } diff --git a/sc/source/filter/rtf/eeimpars.cxx b/sc/source/filter/rtf/eeimpars.cxx index 87018f11e8b5..dcbf6b4e4df3 100644 --- a/sc/source/filter/rtf/eeimpars.cxx +++ b/sc/source/filter/rtf/eeimpars.cxx @@ -107,8 +107,8 @@ sal_uLong ScEEImport::Read( SvStream& rStream, const OUString& rBaseURL ) void ScEEImport::WriteToDocument( bool bSizeColsRows, double nOutputFactor, SvNumberFormatter* pFormatter, bool bConvertDate ) { - ScProgress* pProgress = new ScProgress( mpDoc->GetDocumentShell(), - ScGlobal::GetRscString( STR_LOAD_DOC ), mpParser->ListSize(), true ); + std::unique_ptr<ScProgress> pProgress( new ScProgress( mpDoc->GetDocumentShell(), + ScGlobal::GetRscString( STR_LOAD_DOC ), mpParser->ListSize(), true ) ); sal_uLong nProgress = 0; SCCOL nStartCol, nEndCol; @@ -439,7 +439,7 @@ void ScEEImport::WriteToDocument( bool bSizeColsRows, double nOutputFactor, SvNu pProgress->SetState( ++nProgress ); } } - DELETEZ( pProgress ); // SetOptimalHeight has its own ProgressBar + pProgress.reset(); // SetOptimalHeight has its own ProgressBar // Adjust line height, base is 100% zoom Fraction aZoom( 1, 1 ); // Factor is printer to display ratio @@ -476,7 +476,6 @@ void ScEEImport::WriteToDocument( bool bSizeColsRows, double nOutputFactor, SvNu } } } - delete pProgress; } bool ScEEImport::GraphicSize( SCCOL nCol, SCROW nRow, SCTAB /*nTab*/, ScEEParseEntry* pE ) diff --git a/sc/source/ui/view/formatsh.cxx b/sc/source/ui/view/formatsh.cxx index 28f3fd6e46c0..aa002d698359 100644 --- a/sc/source/ui/view/formatsh.cxx +++ b/sc/source/ui/view/formatsh.cxx @@ -1174,7 +1174,7 @@ void ScFormatShell::ExecuteNumFormat( SfxRequest& rReq ) { OUString aCode = static_cast<const SfxStringItem*>(pItem)->GetValue(); sal_uInt16 aLen = aCode.getLength(); - OUString* sFormat = new OUString[4]; + std::unique_ptr<OUString[]> sFormat( new OUString[4] ); OUString sTmpStr = ""; sal_uInt16 nCount(0); sal_uInt16 nStrCount(0); @@ -1213,7 +1213,6 @@ void ScFormatShell::ExecuteNumFormat( SfxRequest& rReq ) nPrecision, nLeadZeroes); pTabViewShell->SetNumFmtByStr(aCode); - delete[] sFormat; } } break; |