From b27fee9e0ebb445ce82baeade3b249807dca392b Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Wed, 10 Jan 2018 11:44:28 +0200 Subject: loplugin:useuniqueptr cppu,idlc,io,ucbhelper Change-Id: I6d8c24fabd52b39c66ce0b88b547df7ec85dad76 Reviewed-on: https://gerrit.libreoffice.org/47725 Tested-by: Jenkins Reviewed-by: Noel Grandin --- cppu/source/AffineBridge/AffineBridge.cxx | 13 ++++++------- .../helper/purpenv/helper_purpenv_Environment.cxx | 5 +++-- cppu/source/typelib/typelib.cxx | 18 ++++++------------ 3 files changed, 15 insertions(+), 21 deletions(-) (limited to 'cppu') diff --git a/cppu/source/AffineBridge/AffineBridge.cxx b/cppu/source/AffineBridge/AffineBridge.cxx index b63b8777a0dd..9926d56ca0ab 100644 --- a/cppu/source/AffineBridge/AffineBridge.cxx +++ b/cppu/source/AffineBridge/AffineBridge.cxx @@ -26,6 +26,7 @@ #include #include #include +#include class InnerThread; @@ -46,14 +47,14 @@ public: osl::Mutex m_innerMutex; oslThreadIdentifier m_innerThreadId; - InnerThread * m_pInnerThread; + std::unique_ptr m_pInnerThread; osl::Condition m_innerCondition; sal_Int32 m_enterCount; osl::Mutex m_outerMutex; oslThreadIdentifier m_outerThreadId; osl::Condition m_outerCondition; - OuterThread * m_pOuterThread; + std::unique_ptr m_pOuterThread; explicit AffineBridge(); virtual ~AffineBridge() override; @@ -149,12 +150,11 @@ AffineBridge::~AffineBridge() m_pInnerThread->join(); } - delete m_pInnerThread; + m_pInnerThread.reset(); if (m_pOuterThread) { m_pOuterThread->join(); - delete m_pOuterThread; } } @@ -238,7 +238,7 @@ void AffineBridge::v_callInto_v(uno_EnvCallee * pCallee, va_list * pParam) if (m_innerThreadId == 0) // no inner thread yet { - m_pInnerThread = new InnerThread(this); + m_pInnerThread.reset(new InnerThread(this)); m_pInnerThread->resume(); } @@ -275,10 +275,9 @@ void AffineBridge::v_callOut_v(uno_EnvCallee * pCallee, va_list * pParam) if (m_pOuterThread) { m_pOuterThread->join(); - delete m_pOuterThread; } - m_pOuterThread = new OuterThread(this); + m_pOuterThread.reset(new OuterThread(this)); } } diff --git a/cppu/source/helper/purpenv/helper_purpenv_Environment.cxx b/cppu/source/helper/purpenv/helper_purpenv_Environment.cxx index 8d24442faa11..d1de047f4679 100644 --- a/cppu/source/helper/purpenv/helper_purpenv_Environment.cxx +++ b/cppu/source/helper/purpenv/helper_purpenv_Environment.cxx @@ -26,6 +26,7 @@ #include #include +#include extern "C" { typedef void EnvFun_P (uno_Environment *); @@ -95,7 +96,7 @@ public: protected: oslInterlockedCount m_nRef; uno_Environment * m_pEnv; - cppu::Enterable * m_pEnterable; + std::unique_ptr m_pEnterable; EnvFun_P * m_env_acquire; EnvFun_P * m_env_release; @@ -263,7 +264,7 @@ Base::~Base() m_pEnv->pReserved = nullptr; - delete m_pEnterable; + m_pEnterable.reset(); m_pEnv->release(m_pEnv); } diff --git a/cppu/source/typelib/typelib.cxx b/cppu/source/typelib/typelib.cxx index a99746ef0600..1077761710d7 100644 --- a/cppu/source/typelib/typelib.cxx +++ b/cppu/source/typelib/typelib.cxx @@ -23,6 +23,7 @@ #include #include #include +#include #include #include @@ -174,11 +175,11 @@ struct TypeDescriptor_Init_Impl // all type description references WeakMap_Impl * pWeakMap; // all type description callbacks - CallbackSet_Impl * pCallbacks; + std::unique_ptr pCallbacks; // A cache to hold descriptions TypeDescriptionList_Impl * pCache; // The mutex to guard all type library accesses - Mutex * pMutex; + std::unique_ptr pMutex; inline Mutex & getMutex(); @@ -217,7 +218,7 @@ inline Mutex & TypeDescriptor_Init_Impl::getMutex() { MutexGuard aGuard( Mutex::getGlobalMutex() ); if( !pMutex ) - pMutex = new Mutex(); + pMutex.reset(new Mutex()); } return * pMutex; } @@ -318,14 +319,7 @@ TypeDescriptor_Init_Impl::~TypeDescriptor_Init_Impl() #endif SAL_INFO_IF( pCallbacks && !pCallbacks->empty(), "cppu.typelib", "pCallbacks is not NULL or empty" ); - delete pCallbacks; - pCallbacks = nullptr; - - if( pMutex ) - { - delete pMutex; - pMutex = nullptr; - } + pCallbacks.reset(); }; namespace { struct Init : public rtl::Static< TypeDescriptor_Init_Impl, Init > {}; } @@ -338,7 +332,7 @@ extern "C" void SAL_CALL typelib_typedescription_registerCallback( TypeDescriptor_Init_Impl &rInit = Init::get(); // OslGuard aGuard( rInit.getMutex() ); if( !rInit.pCallbacks ) - rInit.pCallbacks = new CallbackSet_Impl; + rInit.pCallbacks.reset(new CallbackSet_Impl); rInit.pCallbacks->push_back( CallbackEntry( pContext, pCallback ) ); } -- cgit