summaryrefslogtreecommitdiff
path: root/store
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2016-09-30 10:18:19 +0200
committerStephan Bergmann <sbergman@redhat.com>2016-09-30 11:06:19 +0200
commit2950528c51b175ae704c674010d8538e3e83da08 (patch)
treec39ba6a5e39238f7fe965ec1b2aada3065f1b208 /store
parent673fe197751cca6477c851f6a64674ced768bc49 (diff)
No need for rtl_cache_* here
...which shows that m_pCount will never be null Change-Id: I87c6e4bf5d258c59a8e91cd194c64b1ce85b4445
Diffstat (limited to 'store')
-rw-r--r--store/source/storbase.cxx33
-rw-r--r--store/source/storbase.hxx38
2 files changed, 7 insertions, 64 deletions
diff --git a/store/source/storbase.cxx b/store/source/storbase.cxx
index bb2cf277fd04..7e2a8cde8699 100644
--- a/store/source/storbase.cxx
+++ b/store/source/storbase.cxx
@@ -33,39 +33,6 @@ using namespace store;
/*========================================================================
*
- * SharedCount::Allocator.
- *
- *======================================================================*/
-SharedCount::Allocator &
-SharedCount::Allocator::get()
-{
- static Allocator g_aSharedCountAllocator;
- return g_aSharedCountAllocator;
-}
-
-SharedCount::Allocator::Allocator()
-{
- m_cache = rtl_cache_create (
- "store_shared_count_cache",
- sizeof(long),
- 0, // objalign
- nullptr, // constructor
- nullptr, // destructor
- nullptr, // reclaim
- nullptr, // userarg
- nullptr, // default source
- 0 // flags
- );
-}
-
-SharedCount::Allocator::~Allocator()
-{
- rtl_cache_destroy (m_cache);
- m_cache = nullptr;
-}
-
-/*========================================================================
- *
* PageData::Allocator_Impl (default allocator).
*
*======================================================================*/
diff --git a/store/source/storbase.hxx b/store/source/storbase.hxx
index b861047c56bd..a4be84752c2f 100644
--- a/store/source/storbase.hxx
+++ b/store/source/storbase.hxx
@@ -84,42 +84,18 @@ class SharedCount
{
long * m_pCount;
- class Allocator
- {
- rtl_cache_type * m_cache;
-
- public:
- static Allocator & get();
-
- long * alloc()
- {
- return static_cast<long*>(rtl_cache_alloc (m_cache));
- }
- void free (long * pCount)
- {
- rtl_cache_free (m_cache, pCount);
- }
-
- protected:
- Allocator();
- ~Allocator();
- };
-
public:
SharedCount()
- : m_pCount(Allocator::get().alloc())
+ : m_pCount(new long)
{
- if (m_pCount != nullptr) (*m_pCount) = 1;
+ (*m_pCount) = 1;
}
~SharedCount()
{
- if (m_pCount != nullptr)
- {
- long new_count = --(*m_pCount);
- if (new_count == 0)
- Allocator::get().free(m_pCount);
- }
+ long new_count = --(*m_pCount);
+ if (new_count == 0)
+ delete m_pCount;
}
void swap (SharedCount & rhs) // nothrow
@@ -130,7 +106,7 @@ public:
SharedCount (SharedCount const & rhs) // nothrow
: m_pCount (rhs.m_pCount)
{
- if (m_pCount != nullptr) ++(*m_pCount);
+ ++(*m_pCount);
}
SharedCount & operator= (SharedCount const & rhs) // nothrow
{
@@ -141,7 +117,7 @@ public:
bool operator== (long count) const
{
- return (m_pCount != nullptr) && (*m_pCount == count);
+ return *m_pCount == count;
}
};