diff options
author | Caolán McNamara <caolanm@redhat.com> | 2011-09-11 22:18:08 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2011-09-12 09:10:02 +0100 |
commit | 6022aab435c48bbfc29bd2c0826dae25bf8655a3 (patch) | |
tree | 2025bb67ac19ebb2ae607b9e4bcdf1f67092acf3 /svl | |
parent | 4f675d31b5d8e82d052dcc3e8d8785087d4e3c90 (diff) |
ensure dtor gets called, and fix dtor and namespaces
Diffstat (limited to 'svl')
-rw-r--r-- | svl/source/misc/adrparse.cxx | 8 | ||||
-rw-r--r-- | svl/source/misc/inettype.cxx | 11 | ||||
-rw-r--r-- | svl/source/misc/svldata.cxx | 45 |
3 files changed, 26 insertions, 38 deletions
diff --git a/svl/source/misc/adrparse.cxx b/svl/source/misc/adrparse.cxx index b6aa9d9e6ff2..7a288a11c1bf 100644 --- a/svl/source/misc/adrparse.cxx +++ b/svl/source/misc/adrparse.cxx @@ -31,12 +31,8 @@ #include <tools/inetmime.hxx> #include <svl/adrparse.hxx> -namespace unnamed_svl_adrparse {} -using namespace unnamed_svl_adrparse; - // unnamed namespaces don't work well yet - -//============================================================================ -namespace unnamed_svl_adrparse { +namespace +{ enum ElementType { ELEMENT_START, ELEMENT_DELIM, ELEMENT_ITEM, ELEMENT_END }; diff --git a/svl/source/misc/inettype.cxx b/svl/source/misc/inettype.cxx index 6234bc0dbe02..686056e21ac1 100644 --- a/svl/source/misc/inettype.cxx +++ b/svl/source/misc/inettype.cxx @@ -40,12 +40,8 @@ #undef _SVSTDARR_STRINGSSORT #endif -namespace unnamed_svl_inettype {} -using namespace unnamed_svl_inettype; - // unnamed namespaces don't work well yet - -//============================================================================ -namespace unnamed_svl_inettype { +namespace +{ //============================================================================ struct MediaTypeEntry @@ -790,7 +786,8 @@ INetContentType Registration::GetContentType4Extension(UniString const & // //============================================================================ -namespace unnamed_svl_inettype { +namespace +{ MediaTypeEntry const * seekEntry(UniString const & rTypeName, MediaTypeEntry const * pMap, sal_Size nSize) diff --git a/svl/source/misc/svldata.cxx b/svl/source/misc/svldata.cxx index b76c1c002ce8..c03ee02acb82 100644 --- a/svl/source/misc/svldata.cxx +++ b/svl/source/misc/svldata.cxx @@ -34,32 +34,24 @@ #include <tools/shl.hxx> #include <svl/svldata.hxx> -namespace unnamed_svl_svldata {} -using namespace unnamed_svl_svldata; - // unnamed namespaces don't work well yet - -//============================================================================ -namespace unnamed_svl_svldata { - -typedef std::map< rtl::OUString, SimpleResMgr * > SimpleResMgrMap; - +namespace +{ + typedef std::map< rtl::OUString, SimpleResMgr * > SimpleResMgrMap; } -//============================================================================ -// -// ImpSvlData -// -//============================================================================ - -static ImpSvlData* pSvlData = 0; - ImpSvlData::~ImpSvlData() { - for (SimpleResMgrMap::iterator t - = static_cast< SimpleResMgrMap * >(m_pThreadsafeRMs)->begin(); - t != static_cast< SimpleResMgrMap * >(m_pThreadsafeRMs)->end(); ++t) - delete t->second; - delete static_cast< SimpleResMgrMap * >(m_pThreadsafeRMs); + if (m_pThreadsafeRMs) + { + SimpleResMgrMap *pThreadsafeRMs = + static_cast<SimpleResMgrMap*>(m_pThreadsafeRMs); + for (SimpleResMgrMap::iterator t = pThreadsafeRMs->begin(), + end = pThreadsafeRMs->end(); t != end; ++t) + { + delete t->second; + } + delete pThreadsafeRMs; + } } //============================================================================ @@ -80,13 +72,16 @@ SimpleResMgr* ImpSvlData::GetSimpleRM(const ::com::sun::star::lang::Locale& rLoc return rResMgr; } +namespace +{ + class theSvlData : public rtl::Static< ImpSvlData, theSvlData > {}; +} + //============================================================================ // static ImpSvlData & ImpSvlData::GetSvlData() { - if (!pSvlData) - pSvlData= new ImpSvlData; - return *pSvlData; + return theSvlData::get(); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |