Boost logo

Boost-Commit :

From: igaztanaga_at_[hidden]
Date: 2007-11-21 11:19:19


Author: igaztanaga
Date: 2007-11-21 11:19:19 EST (Wed, 21 Nov 2007)
New Revision: 41281
URL: http://svn.boost.org/trac/boost/changeset/41281

Log:
Fixed offset_ptr issues with volatile values.
Text files modified:
   trunk/boost/interprocess/containers/vector.hpp | 12 ++++++------
   trunk/boost/interprocess/detail/iterators.hpp | 2 +-
   trunk/boost/interprocess/offset_ptr.hpp | 5 +++--
   3 files changed, 10 insertions(+), 9 deletions(-)

Modified: trunk/boost/interprocess/containers/vector.hpp
==============================================================================
--- trunk/boost/interprocess/containers/vector.hpp (original)
+++ trunk/boost/interprocess/containers/vector.hpp 2007-11-21 11:19:19 EST (Wed, 21 Nov 2007)
@@ -408,8 +408,8 @@
    typedef typename base_t::alloc_version alloc_version;
 
    typedef constant_iterator<T, difference_type> cvalue_iterator;
- typedef repeat_iterator<T, difference_type> rp_iterator;
- typedef detail::move_iterator<rp_iterator> repeat_move_it;
+ typedef repeat_iterator<T, difference_type> repeat_it;
+ typedef detail::move_iterator<repeat_it> repeat_move_it;
    //This is the anti-exception array destructor
    //to deallocate values already constructed
    typedef typename detail::if_c
@@ -961,8 +961,8 @@
       //Just call more general insert(pos, size, value) and return iterator
       size_type n = position - begin();
       this->insert(position
- ,repeat_move_it(rp_iterator(mx.get(), 1))
- ,repeat_move_it(rp_iterator()));
+ ,repeat_move_it(repeat_it(mx.get(), 1))
+ ,repeat_move_it(repeat_it()));
       return iterator(this->members_.m_start + n);
    }
    #else
@@ -971,8 +971,8 @@
       //Just call more general insert(pos, size, value) and return iterator
       size_type n = position - begin();
       this->insert(position
- ,repeat_move_it(rp_iterator(mx, 1))
- ,repeat_move_it(rp_iterator()));
+ ,repeat_move_it(repeat_it(mx, 1))
+ ,repeat_move_it(repeat_it()));
       return iterator(this->members_.m_start + n);
    }
    #endif

Modified: trunk/boost/interprocess/detail/iterators.hpp
==============================================================================
--- trunk/boost/interprocess/detail/iterators.hpp (original)
+++ trunk/boost/interprocess/detail/iterators.hpp 2007-11-21 11:19:19 EST (Wed, 21 Nov 2007)
@@ -241,7 +241,7 @@
    repeat_iterator()
       : m_ptr(0), m_num(0){}
 
- repeat_iterator& operator++()
+ this_type& operator++()
    { increment(); return *this; }
    
    this_type operator++(int)

Modified: trunk/boost/interprocess/offset_ptr.hpp
==============================================================================
--- trunk/boost/interprocess/offset_ptr.hpp (original)
+++ trunk/boost/interprocess/offset_ptr.hpp 2007-11-21 11:19:19 EST (Wed, 21 Nov 2007)
@@ -63,14 +63,15 @@
    #if defined(_MSC_VER) && (_MSC_VER >= 1400)
    __declspec(noinline)
    #endif
- void set_offset(const void *ptr)
+ void set_offset(const volatile void *ptr)
    {
+ const char *p = static_cast<const char*>(const_cast<const void*>(ptr));
       //offset == 1 && ptr != 0 is not legal for this pointer
       if(!ptr){
          m_offset = 1;
       }
       else{
- m_offset = detail::char_ptr_cast(ptr) - detail::char_ptr_cast(this);
+ m_offset = p - detail::char_ptr_cast(this);
          BOOST_ASSERT(m_offset != 1);
       }
    }


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