diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-06-21 15:32:52 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-06-22 20:11:50 +0200 |
commit | 200ca388246e525f6e8f909766977f534c0c897e (patch) | |
tree | a1ddcd356bddada68d1510eb409721b6b2564562 /tools | |
parent | ac9db25da2d78f8ecc2ce68ad622cc6012972494 (diff) |
teach useuniqueptr loplugin about calling delete on a param
which is often a useful indicator that the callers can be made to use
std::unique_ptr
Change-Id: Idb1745d1f58dbcf389c9f60f1a5728d7d092ade5
Reviewed-on: https://gerrit.libreoffice.org/56238
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/source/generic/config.cxx | 22 |
1 files changed, 7 insertions, 15 deletions
diff --git a/tools/source/generic/config.cxx b/tools/source/generic/config.cxx index 55ce2bdc03b8..169f6e6455aa 100644 --- a/tools/source/generic/config.cxx +++ b/tools/source/generic/config.cxx @@ -578,35 +578,27 @@ static void ImplDeleteConfigData( ImplConfigData* pData ) pData->mpFirstGroup = nullptr; } -static ImplConfigData* ImplGetConfigData( const OUString& rFileName ) +static std::unique_ptr<ImplConfigData> ImplGetConfigData( const OUString& rFileName ) { - ImplConfigData* pData; - - pData = new ImplConfigData; + std::unique_ptr<ImplConfigData> pData(new ImplConfigData); pData->maFileName = rFileName; pData->mpFirstGroup = nullptr; pData->mnDataUpdateId = 0; pData->meLineEnd = LINEEND_CRLF; pData->mbRead = false; pData->mbIsUTF8BOM = false; - ImplReadConfig( pData ); + ImplReadConfig( pData.get() ); return pData; } -static void ImplFreeConfigData( ImplConfigData* pDelData ) -{ - ImplDeleteConfigData( pDelData ); - delete pDelData; -} - bool Config::ImplUpdateConfig() const { // Re-read file if timestamp differs if ( mpData->mnTimeStamp != ImplSysGetConfigTimeStamp( maFileName ) ) { - ImplDeleteConfigData( mpData ); - ImplReadConfig( mpData ); + ImplDeleteConfigData( mpData.get() ); + ImplReadConfig( mpData.get() ); mpData->mnDataUpdateId++; return true; } @@ -667,7 +659,7 @@ Config::~Config() SAL_INFO("tools.generic", "Config::~Config()" ); Flush(); - ImplFreeConfigData( mpData ); + ImplDeleteConfigData( mpData.get() ); } void Config::SetGroup(const OString& rGroup) @@ -973,7 +965,7 @@ OString Config::ReadKey(sal_uInt16 nKey) const void Config::Flush() { if ( mpData->mbModified ) - ImplWriteConfig( mpData ); + ImplWriteConfig( mpData.get() ); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |