@@ -295,6 +295,18 @@ class pool: protected simple_segregated_storage < typename UserAllocator::size_t
295
295
// ! Called if malloc/ordered_malloc needs to resize the free list.
296
296
void * malloc_need_resize (); // ! Called if malloc needs to resize the free list.
297
297
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
+ }
298
310
299
311
protected:
300
312
details::PODptr<size_type> list; // !< List structure holding ordered blocks.
@@ -717,11 +729,7 @@ void * pool<UserAllocator>::malloc_need_resize()
717
729
}
718
730
const details::PODptr<size_type> node (ptr, POD_size);
719
731
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);
725
733
726
734
// initialize it,
727
735
store ().add_block (node.begin (), node.element_size (), partition_size);
@@ -757,11 +765,7 @@ void * pool<UserAllocator>::ordered_malloc_need_resize()
757
765
}
758
766
const details::PODptr<size_type> node (ptr, POD_size);
759
767
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);
765
769
766
770
// initialize it,
767
771
// (we can use "add_block" here because we know that
@@ -851,11 +855,7 @@ void * pool<UserAllocator>::ordered_malloc(const size_type n)
851
855
store ().add_ordered_block (node.begin () + num_chunks * partition_size,
852
856
node.element_size () - num_chunks * partition_size, partition_size);
853
857
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);
859
859
860
860
// insert it into the list,
861
861
// handle border case.
0 commit comments