diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-09-07 09:59:27 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-09-08 17:50:13 +0200 |
commit | cbf8f81156840bffff524d74d02d70a5530a0a37 (patch) | |
tree | 44ff68cb196965b8eab076933fa662cb29838d5d /xmlhelp/source | |
parent | 4aecbe996349c7767ba3fb1e81db2ef6f94d39ba (diff) |
loplugin:useuniqueptr in xmlhelp
Change-Id: I8a407e0492adf61e1d815cadd5da0a1623c2b23b
Reviewed-on: https://gerrit.libreoffice.org/60191
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'xmlhelp/source')
-rw-r--r-- | xmlhelp/source/cxxhelp/provider/resultsetforquery.cxx | 19 | ||||
-rw-r--r-- | xmlhelp/source/cxxhelp/provider/urlparameter.cxx | 4 |
2 files changed, 9 insertions, 14 deletions
diff --git a/xmlhelp/source/cxxhelp/provider/resultsetforquery.cxx b/xmlhelp/source/cxxhelp/provider/resultsetforquery.cxx index 647bff41e982..92e20e6049d0 100644 --- a/xmlhelp/source/cxxhelp/provider/resultsetforquery.cxx +++ b/xmlhelp/source/cxxhelp/provider/resultsetforquery.cxx @@ -119,7 +119,7 @@ ResultSetForQuery::ResultSetForQuery( const uno::Reference< uno::XComponentConte OUString idxDir; bool bExtension = false; int iDir = 0; - vector< vector<HitItem>* > aIndexFolderResultVectorVector; + vector< vector<HitItem> > aIndexFolderResultVectorVector; bool bTemporary; while( !(idxDir = aIndexFolderIt.nextIndexFolder( bExtension, bTemporary )).isEmpty() ) @@ -236,8 +236,7 @@ ResultSetForQuery::ResultSetForQuery( const uno::Reference< uno::XComponentConte sort( aIndexFolderResultVector.begin(), aIndexFolderResultVector.end() ); } - vector<HitItem>* pIndexFolderHitItemVector = new vector<HitItem>( aIndexFolderResultVector ); - aIndexFolderResultVectorVector.push_back( pIndexFolderHitItemVector ); + aIndexFolderResultVectorVector.push_back( std::move(aIndexFolderResultVector) ); aIndexFolderResultVector.clear(); } catch (const Exception &e) @@ -254,7 +253,7 @@ ResultSetForQuery::ResultSetForQuery( const uno::Reference< uno::XComponentConte int nVectorCount = aIndexFolderResultVectorVector.size(); - vector<HitItem>::size_type* pCurrentVectorIndex = new vector<HitItem>::size_type[nVectorCount]; + std::unique_ptr<std::vector<HitItem>::size_type[]> pCurrentVectorIndex(new vector<HitItem>::size_type[nVectorCount]); for( int j = 0 ; j < nVectorCount ; ++j ) pCurrentVectorIndex[j] = 0; @@ -266,7 +265,7 @@ ResultSetForQuery::ResultSetForQuery( const uno::Reference< uno::XComponentConte float fBestScore = 0.0; for( int k = 0 ; k < nVectorCount ; ++k ) { - vector<HitItem>& rIndexFolderVector = *aIndexFolderResultVectorVector[k]; + vector<HitItem>& rIndexFolderVector = aIndexFolderResultVectorVector[k]; if( pCurrentVectorIndex[k] < rIndexFolderVector.size() ) { const HitItem& rItem = rIndexFolderVector[ pCurrentVectorIndex[k] ]; @@ -282,7 +281,7 @@ ResultSetForQuery::ResultSetForQuery( const uno::Reference< uno::XComponentConte if( iVectorWithBestScore == -1 ) // No item left at all break; - vector<HitItem>& rIndexFolderVector = *aIndexFolderResultVectorVector[iVectorWithBestScore]; + vector<HitItem>& rIndexFolderVector = aIndexFolderResultVectorVector[iVectorWithBestScore]; const HitItem& rItem = rIndexFolderVector[ pCurrentVectorIndex[iVectorWithBestScore] ]; pCurrentVectorIndex[iVectorWithBestScore]++; @@ -291,12 +290,8 @@ ResultSetForQuery::ResultSetForQuery( const uno::Reference< uno::XComponentConte ++nHitCount; } - delete[] pCurrentVectorIndex; - for( int n = 0 ; n < nVectorCount ; ++n ) - { - vector<HitItem>* pIndexFolderVector = aIndexFolderResultVectorVector[n]; - delete pIndexFolderVector; - } + pCurrentVectorIndex.reset(); + aIndexFolderResultVectorVector.clear(); sal_Int32 replIdx = OUString( "#HLP#" ).getLength(); OUString replWith = "vnd.sun.star.help://"; diff --git a/xmlhelp/source/cxxhelp/provider/urlparameter.cxx b/xmlhelp/source/cxxhelp/provider/urlparameter.cxx index 8707e3a478b2..85e4cb4051ad 100644 --- a/xmlhelp/source/cxxhelp/provider/urlparameter.cxx +++ b/xmlhelp/source/cxxhelp/provider/urlparameter.cxx @@ -338,7 +338,7 @@ void URLParameter::open( const Reference< XOutputStream >& xDataSink ) return; // a standard document or else an active help text, plug in the new input stream - InputStreamTransformer* p = new InputStreamTransformer( this,m_pDatabases,isRoot() ); + std::unique_ptr<InputStreamTransformer> p(new InputStreamTransformer( this,m_pDatabases,isRoot() )); try { xDataSink->writeBytes( Sequence< sal_Int8 >( reinterpret_cast<const sal_Int8*>(p->getData().getStr()), p->getData().getLength() ) ); @@ -346,7 +346,7 @@ void URLParameter::open( const Reference< XOutputStream >& xDataSink ) catch( const Exception& ) { } - delete p; + p.reset(); xDataSink->closeOutput(); } |