@@ -295,6 +295,18 @@ class pool: protected simple_segregated_storage < typename UserAllocator::size_t
295295 // ! Called if malloc/ordered_malloc needs to resize the free list.
296296 void * malloc_need_resize (); // ! Called if malloc needs to resize the free list.
297297 void * ordered_malloc_need_resize (); // ! Called if ordered_malloc needs to resize the free list.
298+ void advance_next (size_type partition_size)
299+ {
300+ BOOST_USING_STD_MIN ();
301+ size_type nnext_size;
302+ if (!max_size)
303+ nnext_size = next_size << 1 ;
304+ else if (next_size*partition_size/requested_size < max_size)
305+ nnext_size = min BOOST_PREVENT_MACRO_SUBSTITUTION (next_size << 1 , max_size * requested_size / partition_size);
306+ else
307+ return ;
308+ next_size = min BOOST_PREVENT_MACRO_SUBSTITUTION (nnext_size, max_chunks ());
309+ }
298310
299311 protected:
300312 details::PODptr<size_type> list; // !< List structure holding ordered blocks.
@@ -717,11 +729,7 @@ void * pool<UserAllocator>::malloc_need_resize()
717729 }
718730 const details::PODptr<size_type> node (ptr, POD_size);
719731
720- BOOST_USING_STD_MIN ();
721- if (!max_size)
722- set_next_size (next_size << 1 );
723- else if ( next_size*partition_size/requested_size < max_size)
724- set_next_size (min BOOST_PREVENT_MACRO_SUBSTITUTION (next_size << 1 , max_size * requested_size / partition_size));
732+ advance_next (partition_size);
725733
726734 // initialize it,
727735 store ().add_block (node.begin (), node.element_size (), partition_size);
@@ -757,11 +765,7 @@ void * pool<UserAllocator>::ordered_malloc_need_resize()
757765 }
758766 const details::PODptr<size_type> node (ptr, POD_size);
759767
760- BOOST_USING_STD_MIN ();
761- if (!max_size)
762- set_next_size (next_size << 1 );
763- else if ( next_size*partition_size/requested_size < max_size)
764- set_next_size (min BOOST_PREVENT_MACRO_SUBSTITUTION (next_size << 1 , max_size * requested_size / partition_size));
768+ advance_next (partition_size);
765769
766770 // initialize it,
767771 // (we can use "add_block" here because we know that
@@ -851,11 +855,7 @@ void * pool<UserAllocator>::ordered_malloc(const size_type n)
851855 store ().add_ordered_block (node.begin () + num_chunks * partition_size,
852856 node.element_size () - num_chunks * partition_size, partition_size);
853857
854- BOOST_USING_STD_MIN ();
855- if (!max_size)
856- set_next_size (next_size << 1 );
857- else if ( next_size*partition_size/requested_size < max_size)
858- set_next_size (min BOOST_PREVENT_MACRO_SUBSTITUTION (next_size << 1 , max_size * requested_size / partition_size));
858+ advance_next (partition_size);
859859
860860 // insert it into the list,
861861 // handle border case.
0 commit comments