[Libreoffice-commits] core.git: xmlsecurity/source
Noel Grandin (via logerrit)
logerrit at kemper.freedesktop.org
Wed Dec 18 07:49:01 UTC 2019
xmlsecurity/source/xmlsec/nss/nssinitializer.cxx | 41 +++++------------------
1 file changed, 9 insertions(+), 32 deletions(-)
New commits:
commit 998ad9b8b1d0eb08b2515ea2086b9f3de58492e7
Author: Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Tue Dec 17 13:40:44 2019 +0200
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Wed Dec 18 08:47:42 2019 +0100
Elide use of rtl_Instance (which is obsoleted by C++11 thread-safe statics)
Change-Id: I522c42d1fe97de2b1a8a629c97cf68e11006a328
Reviewed-on: https://gerrit.libreoffice.org/85327
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/xmlsecurity/source/xmlsec/nss/nssinitializer.cxx b/xmlsecurity/source/xmlsec/nss/nssinitializer.cxx
index e268e6e25d63..421adfdf16e3 100644
--- a/xmlsecurity/source/xmlsec/nss/nssinitializer.cxx
+++ b/xmlsecurity/source/xmlsec/nss/nssinitializer.cxx
@@ -25,7 +25,6 @@
#include <cppuhelper/supportsservice.hxx>
#include <officecfg/Office/Common.hxx>
#include <sal/types.h>
-#include <rtl/instance.hxx>
#include <rtl/bootstrap.hxx>
#include <rtl/string.hxx>
#include <osl/file.hxx>
@@ -158,35 +157,6 @@ salhelper::SingletonRef<InitNSSPrivate>* getInitNSSPrivate()
bool nsscrypto_initialize( const css::uno::Reference< css::uno::XComponentContext > &rxContext, bool & out_nss_init );
-struct InitNSSInitialize
-{
- css::uno::Reference< css::uno::XComponentContext > m_xContext;
-
- explicit InitNSSInitialize(const css::uno::Reference<css::uno::XComponentContext> &rxContext)
- : m_xContext(rxContext)
- {
- }
-
- bool * operator()()
- {
- static bool bInitialized = false;
- bool bNSSInit = false;
- bInitialized = nsscrypto_initialize( m_xContext, bNSSInit );
- if (bNSSInit)
- atexit(nsscrypto_finalize );
- return & bInitialized;
- }
-};
-
-struct GetNSSInitStaticMutex
-{
- ::osl::Mutex* operator()()
- {
- static ::osl::Mutex aNSSInitMutex;
- return &aNSSInitMutex;
- }
-};
-
#ifdef XMLSEC_CRYPTO_NSS
void deleteRootsModule()
@@ -504,8 +474,15 @@ ONSSInitializer::~ONSSInitializer()
bool ONSSInitializer::initNSS( const css::uno::Reference< css::uno::XComponentContext > &rxContext )
{
- return *rtl_Instance< bool, InitNSSInitialize, ::osl::MutexGuard, GetNSSInitStaticMutex >
- ::create( InitNSSInitialize( rxContext ), GetNSSInitStaticMutex() );
+ static bool gbInitialized = [&rxContext]()
+ {
+ bool bNSSInit = false;
+ bool bInitialized = nsscrypto_initialize( rxContext, bNSSInit );
+ if (bNSSInit)
+ atexit(nsscrypto_finalize);
+ return bInitialized;
+ }();
+ return gbInitialized;
}
css::uno::Reference< css::xml::crypto::XDigestContext > SAL_CALL ONSSInitializer::getDigestContext( ::sal_Int32 nDigestID, const css::uno::Sequence< css::beans::NamedValue >& aParams )
More information about the Libreoffice-commits
mailing list