replace double checked locking patterns
with thread safe static initialization Change-Id: I4c751a47e3bdf52bbfb67d4f3aabd6f442e30118 Reviewed-on: https://gerrit.libreoffice.org/58287 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
committed by
Noel Grandin
parent
1eeb8d3476
commit
c9697dc2ab
@@ -158,17 +158,10 @@ struct MappingsData
|
||||
|
||||
static MappingsData & getMappingsData()
|
||||
{
|
||||
static MappingsData * s_p = nullptr;
|
||||
if (! s_p)
|
||||
{
|
||||
MutexGuard aGuard( Mutex::getGlobalMutex() );
|
||||
if (! s_p)
|
||||
{
|
||||
//TODO This memory is leaked; see #i63473# for when this should be
|
||||
// changed again:
|
||||
s_p = new MappingsData;
|
||||
}
|
||||
}
|
||||
//TODO This memory is leaked; see #i63473# for when this should be
|
||||
// changed again:
|
||||
static MappingsData * s_p(new MappingsData);
|
||||
|
||||
return *s_p;
|
||||
}
|
||||
|
||||
|
@@ -112,21 +112,13 @@ void OComponentHelper::release() throw()
|
||||
|
||||
Sequence< Type > OComponentHelper::getTypes()
|
||||
{
|
||||
static OTypeCollection * s_pTypes = nullptr;
|
||||
if (! s_pTypes)
|
||||
{
|
||||
MutexGuard aGuard( Mutex::getGlobalMutex() );
|
||||
if (! s_pTypes)
|
||||
{
|
||||
static OTypeCollection s_aTypes(
|
||||
cppu::UnoType<lang::XComponent>::get(),
|
||||
cppu::UnoType<lang::XTypeProvider>::get(),
|
||||
cppu::UnoType<XAggregation>::get(),
|
||||
cppu::UnoType<XWeak>::get() );
|
||||
s_pTypes = &s_aTypes;
|
||||
}
|
||||
}
|
||||
return s_pTypes->getTypes();
|
||||
static OTypeCollection s_aTypes(
|
||||
cppu::UnoType<lang::XComponent>::get(),
|
||||
cppu::UnoType<lang::XTypeProvider>::get(),
|
||||
cppu::UnoType<XAggregation>::get(),
|
||||
cppu::UnoType<XWeak>::get() );
|
||||
|
||||
return s_aTypes.getTypes();
|
||||
}
|
||||
|
||||
// XComponent
|
||||
|
Reference in New Issue
Block a user