diff options
author | Caolán McNamara <caolanm@redhat.com> | 2011-04-03 21:35:06 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2011-04-03 21:43:48 +0100 |
commit | 44d2445580c8f8c8555a1c94c445805f0305f3bd (patch) | |
tree | 90badb4304ff9c92a3de4bb2da6050048a63eb44 /cppu | |
parent | c0e0ae545baafb9bad697fc861450e120d59c9e1 (diff) |
use rtl::Static where double-locked pattern used
Diffstat (limited to 'cppu')
-rw-r--r-- | cppu/source/uno/lbenv.cxx | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/cppu/source/uno/lbenv.cxx b/cppu/source/uno/lbenv.cxx index 71cda7fe7e40..651e6862fba7 100644 --- a/cppu/source/uno/lbenv.cxx +++ b/cppu/source/uno/lbenv.cxx @@ -825,14 +825,14 @@ extern "C" void SAL_CALL uno_dumpEnvironmentByName( } } -//------------------------------------------------------------------------------ -inline static const OUString & unoenv_getStaticOIdPart() +namespace { - static OUString * s_pStaticOidPart = 0; - if (! s_pStaticOidPart) + class makeOIdPart { - ::osl::MutexGuard guard( ::osl::Mutex::getGlobalMutex() ); - if (! s_pStaticOidPart) + private: + OUString m_sOidPart; + public: + makeOIdPart() { ::rtl::OUStringBuffer aRet( 64 ); aRet.appendAscii( RTL_CONSTASCII_STRINGPARAM("];") ); @@ -856,11 +856,18 @@ inline static const OUString & unoenv_getStaticOIdPart() for ( sal_Int32 i = 0; i < 16; ++i ) aRet.append( (sal_Int32)ar[i], 16 ); - static OUString s_aStaticOidPart( aRet.makeStringAndClear() ); - s_pStaticOidPart = &s_aStaticOidPart; + m_sOidPart = aRet.makeStringAndClear(); } - } - return *s_pStaticOidPart; + const OUString& getOIdPart() const { return m_sOidPart; } + }; + + class theStaticOIdPart : public rtl::Static<makeOIdPart, theStaticOIdPart> {}; +} + +//------------------------------------------------------------------------------ +inline static const OUString & unoenv_getStaticOIdPart() +{ + return theStaticOIdPart::get().getOIdPart(); } extern "C" |