[Boost-bugs] [Boost C++ Libraries] #11312: smart_ptr::detail::as_allocator::allocate() adds alignment padding when it's not needed

Subject: [Boost-bugs] [Boost C++ Libraries] #11312: smart_ptr::detail::as_allocator::allocate() adds alignment padding when it's not needed
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2015-05-15 22:50:38


#11312: smart_ptr::detail::as_allocator::allocate() adds alignment padding when
it's not needed
---------------------------------+-----------------------
 Reporter: David Aue <david@…> | Owner: pdimov
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: smart_ptr
  Version: Boost 1.57.0 | Severity: Problem
 Keywords: |
---------------------------------+-----------------------
 smart_ptr::detail::as_allocator::allocate()
 {
   enum {
      M = boost::alignment_of<type>::value
   };
   std::size_t n1 = count * sizeof(value_type);
   std::size_t n2 = data.size * sizeof(type);
   std::size_t n3 = n2 + M;
   CA ca(allocator());
   void* p1 = ca.allocate(n1 + n3);


 Allocation is for two items of size n1 and n2. Alignment size is added to
 n2 to create n3 to there is room to align n2 properly.

 if n1 % M == 0 then alignment is already fine and the extra M bytes is
 wasted.

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/11312>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:18 UTC