Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r84900 - trunk/boost/container/detail
From: igaztanaga_at_[hidden]
Date: 2013-06-24 15:10:07


Author: igaztanaga
Date: 2013-06-24 15:10:07 EDT (Mon, 24 Jun 2013)
New Revision: 84900
URL: http://svn.boost.org/trac/boost/changeset/84900

Log:
Trivial fix for empty ranges in node_alloc_holder

Text files modified:
   trunk/boost/container/detail/node_alloc_holder.hpp | 82 ++++++++++++++++++++-------------------
   1 files changed, 42 insertions(+), 40 deletions(-)

Modified: trunk/boost/container/detail/node_alloc_holder.hpp
==============================================================================
--- trunk/boost/container/detail/node_alloc_holder.hpp Mon Jun 24 08:25:33 2013 (r84899)
+++ trunk/boost/container/detail/node_alloc_holder.hpp 2013-06-24 15:10:07 EDT (Mon, 24 Jun 2013) (r84900)
@@ -229,48 +229,50 @@
    void allocate_many_and_construct
       (FwdIterator beg, difference_type n, Inserter inserter)
    {
- /*
- NodePtr p = this->allocate_one();
- Deallocator node_deallocator(p, this->node_alloc());
- ::boost::container::construct_in_place(this->node_alloc(), container_detail::addressof(p->m_data), it);
- node_deallocator.release();
- //This does not throw
- typedef typename Node::hook_type hook_type;
- ::new(static_cast<hook_type*>(container_detail::to_raw_pointer(p))) hook_type;
- return (p);
- */
- typedef typename NodeAlloc::multiallocation_chain multiallocation_chain;
-
- //Try to allocate memory in a single block
- typedef typename multiallocation_chain::iterator multialloc_iterator;
- multiallocation_chain mem;
- this->node_alloc().allocate_individual(n, mem);
- multialloc_iterator itbeg(mem.begin()), itlast(mem.last());
- mem.clear();
- Node *p = 0;
- NodeAlloc &nalloc = this->node_alloc();
- BOOST_TRY{
- while(n--){
- p = container_detail::to_raw_pointer(&*itbeg);
- ++itbeg;
- //This can throw
- Deallocator node_deallocator(p, nalloc);
- boost::container::construct_in_place(nalloc, container_detail::addressof(p->m_data), beg);
- ++beg;
- node_deallocator.release();
- //This does not throw
- typedef typename Node::hook_type hook_type;
- ::new(static_cast<hook_type*>(p)) hook_type;
- //This can throw in some containers (predicate might throw)
- inserter(*p);
+ if(n){
+ /*
+ NodePtr p = this->allocate_one();
+ Deallocator node_deallocator(p, this->node_alloc());
+ ::boost::container::construct_in_place(this->node_alloc(), container_detail::addressof(p->m_data), it);
+ node_deallocator.release();
+ //This does not throw
+ typedef typename Node::hook_type hook_type;
+ ::new(static_cast<hook_type*>(container_detail::to_raw_pointer(p))) hook_type;
+ return (p);
+ */
+ typedef typename NodeAlloc::multiallocation_chain multiallocation_chain;
+
+ //Try to allocate memory in a single block
+ typedef typename multiallocation_chain::iterator multialloc_iterator;
+ multiallocation_chain mem;
+ this->node_alloc().allocate_individual(n, mem);
+ multialloc_iterator itbeg(mem.begin()), itlast(mem.last());
+ mem.clear();
+ Node *p = 0;
+ NodeAlloc &nalloc = this->node_alloc();
+ BOOST_TRY{
+ while(n--){
+ p = container_detail::to_raw_pointer(&*itbeg);
+ ++itbeg;
+ //This can throw
+ Deallocator node_deallocator(p, nalloc);
+ boost::container::construct_in_place(nalloc, container_detail::addressof(p->m_data), beg);
+ ++beg;
+ node_deallocator.release();
+ //This does not throw
+ typedef typename Node::hook_type hook_type;
+ ::new(static_cast<hook_type*>(p)) hook_type;
+ //This can throw in some containers (predicate might throw)
+ inserter(*p);
+ }
          }
+ BOOST_CATCH(...){
+ mem.incorporate_after(mem.last(), &*itbeg, &*itlast, n);
+ this->node_alloc().deallocate_individual(mem);
+ BOOST_RETHROW
+ }
+ BOOST_CATCH_END
       }
- BOOST_CATCH(...){
- mem.incorporate_after(mem.last(), &*itbeg, &*itlast, n);
- this->node_alloc().deallocate_individual(mem);
- BOOST_RETHROW
- }
- BOOST_CATCH_END
    }
 
    void clear(allocator_v1)


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