diff options
author | Stephan Bergmann <sb@openoffice.org> | 2001-06-14 13:43:59 +0000 |
---|---|---|
committer | Stephan Bergmann <sb@openoffice.org> | 2001-06-14 13:43:59 +0000 |
commit | 602b07cd5f1ea10a329b530c568906d1e0bab3a6 (patch) | |
tree | ad3ae8028e5ffe60e3f8d8cadcdcb34f837b4e6b /ucb/workben/cachemap | |
parent | 58c291313972f981bd3756df73efa1410f0eb3e3 (diff) |
Fixed wrong use of map::insert().
Diffstat (limited to 'ucb/workben/cachemap')
-rw-r--r-- | ucb/workben/cachemap/cachemapobject3.cxx | 34 |
1 files changed, 20 insertions, 14 deletions
diff --git a/ucb/workben/cachemap/cachemapobject3.cxx b/ucb/workben/cachemap/cachemapobject3.cxx index 693df3a5223b..76acda64a567 100644 --- a/ucb/workben/cachemap/cachemapobject3.cxx +++ b/ucb/workben/cachemap/cachemapobject3.cxx @@ -2,9 +2,9 @@ * * $RCSfile: cachemapobject3.cxx,v $ * - * $Revision: 1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: sb $ $Date: 2001-06-11 13:03:12 $ + * last change: $Author: sb $ $Date: 2001-06-14 14:43:59 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -125,20 +125,26 @@ rtl::Reference< Object3 > ObjectContainer3::get(rtl::OUString const & rKey) { osl::MutexGuard aGuard(m_aMutex); Map::iterator aIt(m_aMap.find(rKey)); - if (aIt != m_aMap.end()) + if (aIt == m_aMap.end()) + { + std::auto_ptr< Object3 > xElement(new Object3(this)); + aIt = m_aMap.insert(Map::value_type(rKey, xElement.get())).first; + aIt->second->m_aContainerIt = aIt; + xElement.release(); + return aIt->second; + } + else if (osl_incrementInterlockedCount(&aIt->second->m_nRefCount) > 1) + { + rtl::Reference< Object3 > xElement(aIt->second); + osl_decrementInterlockedCount(&aIt->second->m_nRefCount); + return xElement; + } + else { - if (osl_incrementInterlockedCount(&aIt->second->m_nRefCount) > 1) - { - rtl::Reference< Object3 > xElement(aIt->second); - osl_decrementInterlockedCount(&aIt->second->m_nRefCount); - return xElement; - } osl_decrementInterlockedCount(&aIt->second->m_nRefCount); aIt->second->m_aContainerIt = m_aMap.end(); + aIt->second = new Object3(this); + aIt->second->m_aContainerIt = aIt; + return aIt->second; } - std::auto_ptr< Object3 > xElement(new Object3(this)); - aIt = m_aMap.insert(Map::value_type(rKey, xElement.get())).first; - aIt->second->m_aContainerIt = aIt; - xElement.release(); - return aIt->second; } |