summaryrefslogtreecommitdiff
path: root/cppu
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2018-01-10 11:44:28 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2018-01-11 07:37:16 +0100
commitb27fee9e0ebb445ce82baeade3b249807dca392b (patch)
treeec602e834d8ac02c0495d1d25e2bed30fa22bfb3 /cppu
parent96d9bd226215194632b6b0b7b0153f41ade1fc47 (diff)
loplugin:useuniqueptr cppu,idlc,io,ucbhelper
Change-Id: I6d8c24fabd52b39c66ce0b88b547df7ec85dad76 Reviewed-on: https://gerrit.libreoffice.org/47725 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'cppu')
-rw-r--r--cppu/source/AffineBridge/AffineBridge.cxx13
-rw-r--r--cppu/source/helper/purpenv/helper_purpenv_Environment.cxx5
-rw-r--r--cppu/source/typelib/typelib.cxx18
3 files changed, 15 insertions, 21 deletions
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 <cppu/Enterable.hxx>
#include <cppu/helper/purpenv/Environment.hxx>
#include <cppu/helper/purpenv/Mapping.hxx>
+#include <memory>
class InnerThread;
@@ -46,14 +47,14 @@ public:
osl::Mutex m_innerMutex;
oslThreadIdentifier m_innerThreadId;
- InnerThread * m_pInnerThread;
+ std::unique_ptr<InnerThread> 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<OuterThread> 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 <typelib/typedescription.h>
#include <osl/interlck.h>
+#include <memory>
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<cppu::Enterable> 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 <list>
#include <set>
#include <vector>
+#include <memory>
#include <stdarg.h>
#include <stdlib.h>
@@ -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<CallbackSet_Impl> pCallbacks;
// A cache to hold descriptions
TypeDescriptionList_Impl * pCache;
// The mutex to guard all type library accesses
- Mutex * pMutex;
+ std::unique_ptr<Mutex> 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 ) );
}