[Libreoffice-commits] core.git: cppuhelper/source cppu/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Sun Jul 29 21:07:31 UTC 2018


 cppu/source/uno/lbmap.cxx       |   15 ++++-----------
 cppuhelper/source/component.cxx |   22 +++++++---------------
 2 files changed, 11 insertions(+), 26 deletions(-)

New commits:
commit c9697dc2abb2d23ffbb8253ce8b0ff0314d86984
Author:     Jochen Nitschke <j.nitschke+logerrit at ok.de>
AuthorDate: Sun Jul 29 18:22:48 2018 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Sun Jul 29 23:06:39 2018 +0200

    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 at collabora.co.uk>

diff --git a/cppu/source/uno/lbmap.cxx b/cppu/source/uno/lbmap.cxx
index e1c606bf5c67..c5ce6709991f 100644
--- a/cppu/source/uno/lbmap.cxx
+++ b/cppu/source/uno/lbmap.cxx
@@ -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;
 }
 
diff --git a/cppuhelper/source/component.cxx b/cppuhelper/source/component.cxx
index 1c3585ee17d4..c9bd6a4a9b28 100644
--- a/cppuhelper/source/component.cxx
+++ b/cppuhelper/source/component.cxx
@@ -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


More information about the Libreoffice-commits mailing list