@@ -138,8 +138,8 @@ class node_allocator
138138 // !Returns the number of elements that could be allocated.
139139 // !Never throws
140140 BOOST_CONTAINER_NODISCARD
141- size_type max_size () const
142- { return size_type (-1 )/sizeof (T); }
141+ size_type max_size () const BOOST_NOEXCEPT_OR_NOTHROW
142+ { return size_type (-1 )/( 2u * sizeof (T) ); }
143143
144144 // !Allocate memory for an array of count elements.
145145 // !Throws bad_alloc if there is no enough memory
@@ -325,22 +325,21 @@ class node_allocator
325325 private:
326326 pointer priv_allocation_command
327327 (allocation_type command, std::size_t limit_size
328- ,size_type &prefer_in_recvd_out_size
329- ,pointer &reuse)
328+ ,size_type &prefer_in_recvd_out_size, pointer &reuse_ptr)
330329 {
331330 std::size_t const preferred_size = prefer_in_recvd_out_size;
332331 dlmalloc_command_ret_t ret = {0 , 0 };
333- if ((limit_size > this ->max_size ()) || ( preferred_size > this ->max_size ())){
332+ if (BOOST_UNLIKELY (limit_size > this ->max_size () || preferred_size > this ->max_size ())){
334333 return pointer ();
335334 }
336335 std::size_t l_size = limit_size*sizeof (T);
337336 std::size_t p_size = preferred_size*sizeof (T);
338337 std::size_t r_size;
339338 {
340- void * reuse_ptr_void = reuse ;
339+ void * reuse_ptr_void = reuse_ptr ;
341340 ret = dlmalloc_allocation_command ( command, sizeof (T), dtl::alignment_of<T>::value
342341 , l_size, p_size, &r_size, reuse_ptr_void);
343- reuse = static_cast <T*>(reuse_ptr_void);
342+ reuse_ptr = ret. second ? static_cast <T*>(reuse_ptr_void) : 0 ;
344343 }
345344 prefer_in_recvd_out_size = r_size/sizeof (T);
346345 return (pointer)ret.first ;
0 commit comments