From 6a017237e01a25ce6901d1cf85ac0408f8935b11 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Tue, 8 May 2018 09:44:04 +0200 Subject: loplugin:useuniqueptr in helpdatafileproxy::Hdf Change-Id: I4324a290b826d76f89319f556aededb30d921f8d Reviewed-on: https://gerrit.libreoffice.org/54166 Tested-by: Jenkins Reviewed-by: Noel Grandin --- xmlhelp/source/cxxhelp/provider/db.cxx | 20 ++++++++------------ xmlhelp/source/cxxhelp/provider/db.hxx | 7 +++---- 2 files changed, 11 insertions(+), 16 deletions(-) (limited to 'xmlhelp') diff --git a/xmlhelp/source/cxxhelp/provider/db.cxx b/xmlhelp/source/cxxhelp/provider/db.cxx index 9c3c2fa9fe2a..c99a07403104 100644 --- a/xmlhelp/source/cxxhelp/provider/db.cxx +++ b/xmlhelp/source/cxxhelp/provider/db.cxx @@ -68,13 +68,13 @@ void Hdf::createHashMap( bool bOptimizeForPerformance ) { if( m_pStringToDataMap != nullptr ) return; - m_pStringToDataMap = new StringToDataMap; + m_pStringToDataMap.reset(new StringToDataMap); } else { if( m_pStringToValPosMap != nullptr ) return; - m_pStringToValPosMap = new StringToValPosMap; + m_pStringToValPosMap.reset(new StringToValPosMap); } Reference< XInputStream > xIn = m_xSFA->openFileRead( m_aFileURL ); @@ -123,19 +123,15 @@ void Hdf::createHashMap( bool bOptimizeForPerformance ) void Hdf::releaseHashMap() { - if( m_pStringToDataMap != nullptr ) - { - delete m_pStringToDataMap; - m_pStringToDataMap = nullptr; - } - if( m_pStringToValPosMap != nullptr ) - { - delete m_pStringToValPosMap; - m_pStringToValPosMap = nullptr; - } + m_pStringToDataMap.reset(); + m_pStringToValPosMap.reset(); } +Hdf::~Hdf() +{ +} + bool Hdf::getValueForKey( const OString& rKey, HDFData& rValue ) { bool bSuccess = false; diff --git a/xmlhelp/source/cxxhelp/provider/db.hxx b/xmlhelp/source/cxxhelp/provider/db.hxx index e0d7d60e9c40..b26797c80593 100644 --- a/xmlhelp/source/cxxhelp/provider/db.hxx +++ b/xmlhelp/source/cxxhelp/provider/db.hxx @@ -52,8 +52,8 @@ namespace helpdatafileproxy { class Hdf { OUString m_aFileURL; - StringToDataMap* m_pStringToDataMap; - StringToValPosMap* m_pStringToValPosMap; + std::unique_ptr m_pStringToDataMap; + std::unique_ptr m_pStringToValPosMap; css::uno::Reference< css::ucb::XSimpleFileAccess3 > m_xSFA; @@ -81,8 +81,7 @@ namespace helpdatafileproxy { { OSL_ASSERT(comphelper::isFileUrl(rFileURL)); } - ~Hdf() - { releaseHashMap(); } + ~Hdf(); void createHashMap( bool bOptimizeForPerformance ); void releaseHashMap(); -- cgit