|
Boost-Commit : |
From: xushiweizh_at_[hidden]
Date: 2008-04-30 02:17:08
Author: xushiwei
Date: 2008-04-30 02:17:08 EDT (Wed, 30 Apr 2008)
New Revision: 44913
URL: http://svn.boost.org/trac/boost/changeset/44913
Log:
ticket #1885: gc_alloc defects - gc_alloc::destroy, destroyArray
Text files modified:
sandbox/memory/boost/memory/gc_alloc.hpp | 42 ++++++++++++++++++++++++++++++++-------
sandbox/memory/boost/memory/stl/queue.hpp | 24 +++++++++++-----------
2 files changed, 46 insertions(+), 20 deletions(-)
Modified: sandbox/memory/boost/memory/gc_alloc.hpp
==============================================================================
--- sandbox/memory/boost/memory/gc_alloc.hpp (original)
+++ sandbox/memory/boost/memory/gc_alloc.hpp 2008-04-30 02:17:08 EDT (Wed, 30 Apr 2008)
@@ -395,6 +395,38 @@
}
}
+private:
+ template <class Type>
+ void BOOST_MEMORY_CALL _Destroy(Type* obj, destructor_t)
+ {
+ obj->~Type();
+ _MemHeaderEx* p = (_MemHeaderEx*)obj - 1;
+ p->blkType = nodeFree;
+ }
+
+ template <class Type>
+ void BOOST_MEMORY_CALL _Destroy(Type* obj, int)
+ {
+ _MemHeader* p = (_MemHeader*)obj - 1;
+ p->blkType = nodeFree;
+ }
+
+ template <class Type>
+ void BOOST_MEMORY_CALL _DestroyArray(Type* array, size_t count, destructor_t)
+ {
+ destructor_traits<Type>::destructArrayN(array, count);
+ void* pData = destructor_traits<Type>::getArrayBuffer(array);
+ _MemHeaderEx* p = (_MemHeaderEx*)pData - 1;
+ p->blkType = nodeFree;
+ }
+
+ template <class Type>
+ void BOOST_MEMORY_CALL _DestroyArray(Type* array, size_t count, int)
+ {
+ _MemHeader* p = (_MemHeader*)array - 1;
+ p->blkType = nodeFree;
+ }
+
public:
template <class Type>
void BOOST_MEMORY_CALL destroy(Type* obj)
@@ -402,10 +434,7 @@
BOOST_MEMORY_ASSERT( _IsValid(obj) );
BOOST_MEMORY_ASSERT( sizeof(Type) < AllocSizeHuge );
- obj->~Type();
-
- _MemHeaderEx* p = (_MemHeaderEx*)obj - 1;
- p->blkType = nodeFree;
+ _Destroy(obj, destructor_traits<Type>::destruct);
}
template <class Type>
@@ -431,10 +460,7 @@
}
else
{
- destructor_traits<Type>::destructArrayN(array, count);
- void* pData = destructor_traits<Type>::getArrayBuffer(array);
- _MemHeaderEx* p = (_MemHeaderEx*)pData - 1;
- p->blkType = nodeFree;
+ _DestroyArray(array, count, destructor_traits<Type>::destruct);
}
}
Modified: sandbox/memory/boost/memory/stl/queue.hpp
==============================================================================
--- sandbox/memory/boost/memory/stl/queue.hpp (original)
+++ sandbox/memory/boost/memory/stl/queue.hpp 2008-04-30 02:17:08 EDT (Wed, 30 Apr 2008)
@@ -48,32 +48,32 @@
protected:
_Sequence m_coll;
- _Pred comp;
+ _Pred m_pred;
public:
priority_queue() {}
- explicit priority_queue(const _Pred& __x) : m_coll(), comp(__x) {}
+ explicit priority_queue(const _Pred& __x) : m_coll(), m_pred(__x) {}
priority_queue(const _Pred& __x, const _Sequence& __s)
- : m_coll(__s), comp(__x)
- { std::make_heap(m_coll.begin(), m_coll.end(), comp); }
+ : m_coll(__s), m_pred(__x)
+ { std::make_heap(m_coll.begin(), m_coll.end(), m_pred); }
template <class _InputIterator>
priority_queue(_InputIterator __first, _InputIterator __last)
- : m_coll(__first, __last) { std::make_heap(m_coll.begin(), m_coll.end(), comp); }
+ : m_coll(__first, __last) { std::make_heap(m_coll.begin(), m_coll.end(), m_pred); }
template <class _InputIterator>
priority_queue(_InputIterator __first,
_InputIterator __last, const _Pred& __x)
- : m_coll(__first, __last), comp(__x)
- { std::make_heap(m_coll.begin(), m_coll.end(), comp); }
+ : m_coll(__first, __last), m_pred(__x)
+ { std::make_heap(m_coll.begin(), m_coll.end(), m_pred); }
template <class _InputIterator>
priority_queue(_InputIterator __first, _InputIterator __last,
const _Pred& __x, const _Sequence& __s)
- : m_coll(__s), comp(__x)
- {
+ : m_coll(__s), m_pred(__x)
+ {
m_coll.insert(m_coll.end(), __first, __last);
- std::make_heap(m_coll.begin(), m_coll.end(), comp);
+ std::make_heap(m_coll.begin(), m_coll.end(), m_pred);
}
bool empty() const { return m_coll.empty(); }
@@ -81,10 +81,10 @@
const_reference top() const { return m_coll.front(); }
void push(const value_type& __x) {
m_coll.push_back(__x);
- std::push_heap(m_coll.begin(), m_coll.end(), comp);
+ std::push_heap(m_coll.begin(), m_coll.end(), m_pred);
}
void pop() {
- std::pop_heap(m_coll.begin(), m_coll.end(), comp);
+ std::pop_heap(m_coll.begin(), m_coll.end(), m_pred);
m_coll.pop_back();
}
void clear() {
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk