Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r49872 - trunk/boost/interprocess/containers/detail
From: igaztanaga_at_[hidden]
Date: 2008-11-22 06:07:36


Author: igaztanaga
Date: 2008-11-22 06:07:35 EST (Sat, 22 Nov 2008)
New Revision: 49872
URL: http://svn.boost.org/trac/boost/changeset/49872

Log:
Fixed bug with empty ranges.
Text files modified:
   trunk/boost/interprocess/containers/detail/node_alloc_holder.hpp | 46 ++++++++++++++++++++-------------------
   1 files changed, 24 insertions(+), 22 deletions(-)

Modified: trunk/boost/interprocess/containers/detail/node_alloc_holder.hpp
==============================================================================
--- trunk/boost/interprocess/containers/detail/node_alloc_holder.hpp (original)
+++ trunk/boost/interprocess/containers/detail/node_alloc_holder.hpp 2008-11-22 06:07:35 EST (Sat, 22 Nov 2008)
@@ -297,32 +297,34 @@
    FwdIterator allocate_many_and_construct
       (FwdIterator beg, difference_type n, Inserter inserter)
    {
- typedef typename NodeAlloc::multiallocation_iterator multiallocation_iterator;
+ if(n){
+ typedef typename NodeAlloc::multiallocation_iterator multiallocation_iterator;
 
- //Try to allocate memory in a single block
- multiallocation_iterator itbeg =
- this->node_alloc().allocate_individual(n), itend, itold;
- int constructed = 0;
- Node *p = 0;
- BOOST_TRY{
- for(difference_type i = 0; i < n; ++i, ++beg, --constructed){
- p = &*itbeg;
- ++itbeg;
- //This can throw
- boost::interprocess::construct_in_place(p, beg);
- ++constructed;
- //This can throw in some containers (predicate might throw)
- inserter(*p);
+ //Try to allocate memory in a single block
+ multiallocation_iterator itbeg =
+ this->node_alloc().allocate_individual(n), itend, itold;
+ int constructed = 0;
+ Node *p = 0;
+ BOOST_TRY{
+ for(difference_type i = 0; i < n; ++i, ++beg, --constructed){
+ p = &*itbeg;
+ ++itbeg;
+ //This can throw
+ boost::interprocess::construct_in_place(p, beg);
+ ++constructed;
+ //This can throw in some containers (predicate might throw)
+ inserter(*p);
+ }
          }
- }
- BOOST_CATCH(...){
- if(constructed){
- this->destroy(p);
+ BOOST_CATCH(...){
+ if(constructed){
+ this->destroy(p);
+ }
+ this->node_alloc().deallocate_many(itbeg);
+ BOOST_RETHROW
          }
- this->node_alloc().deallocate_many(itbeg);
- BOOST_RETHROW
+ BOOST_CATCH_END
       }
- BOOST_CATCH_END
       return beg;
    }
 


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