@@ -2647,9 +2647,11 @@ private:
26472647 return;
26482648 }
26492649
2650- _My_data._Myres = _BUF_SIZE - 1;
2651- const size_type _New_capacity = _Calculate_growth(_Count);
2652- const pointer _New_ptr = _Al.allocate(_New_capacity + 1); // throws
2650+ _My_data._Myres = _BUF_SIZE - 1;
2651+ size_type _New_capacity = _Calculate_growth(_Count);
2652+ ++_New_capacity;
2653+ const pointer _New_ptr = _Allocate_at_least_helper(_Al, _New_capacity); // throws
2654+ --_New_capacity;
26532655 _Construct_in_place(_My_data._Bx._Ptr, _New_ptr);
26542656
26552657 _Start_element_lifetimes(_Unfancy(_New_ptr), _New_capacity + 1);
@@ -2691,8 +2693,10 @@ private:
26912693 }
26922694
26932695 if (_Count >= _BUF_SIZE) {
2694- const size_type _New_capacity = _Calculate_growth(_Count);
2695- const pointer _New_ptr = _Al.allocate(_New_capacity + 1); // throws
2696+ size_type _New_capacity = _Calculate_growth(_Count);
2697+ ++_New_capacity;
2698+ const pointer _New_ptr = _Allocate_at_least_helper(_Al, _New_capacity); // throws
2699+ --_New_capacity;
26962700 _Construct_in_place(_My_data._Bx._Ptr, _New_ptr);
26972701 _My_data._Myres = _New_capacity;
26982702
@@ -2708,9 +2712,11 @@ private:
27082712 _Xlen_string(); // result too long
27092713 }
27102714
2711- const auto _Old_ptr = _My_data._Myptr();
2712- const size_type _New_capacity = _Calculate_growth(_My_data._Mysize);
2713- const pointer _New_ptr = _Al.allocate(_New_capacity + 1); // throws
2715+ const auto _Old_ptr = _My_data._Myptr();
2716+ size_type _New_capacity = _Calculate_growth(_My_data._Mysize);
2717+ ++_New_capacity;
2718+ const pointer _New_ptr = _Allocate_at_least_helper(_Al, _New_capacity); // throws
2719+ --_New_capacity;
27142720
27152721 _Start_element_lifetimes(_Unfancy(_New_ptr), _New_capacity + 1);
27162722 _Traits::copy(_Unfancy(_New_ptr), _Old_ptr, _My_data._Mysize);
@@ -2792,9 +2798,11 @@ public:
27922798 _Container_proxy_ptr<_Alty> _Proxy(_Alproxy, _My_data); // throws
27932799
27942800 if (_New_capacity < _New_size) {
2795- _New_capacity = _Calculate_growth(_New_size, _BUF_SIZE - 1, max_size());
2796- const pointer _Fancyptr = _Getal().allocate(_New_capacity + 1); // throws
2797- _Ptr = _Unfancy(_Fancyptr);
2801+ _New_capacity = _Calculate_growth(_New_size, _BUF_SIZE - 1, max_size());
2802+ ++_New_capacity;
2803+ const pointer _Fancyptr = _Allocate_at_least_helper(_Getal(), _New_capacity); // throws
2804+ --_New_capacity;
2805+ _Ptr = _Unfancy(_Fancyptr);
27982806 _Construct_in_place(_My_data._Bx._Ptr, _Fancyptr);
27992807
28002808 _Start_element_lifetimes(_Ptr, _New_capacity + 1);
@@ -2863,10 +2871,12 @@ public:
28632871 _Xlen_string();
28642872 }
28652873
2866- const auto _New_capacity = _Calculate_growth(_New_size, _BUF_SIZE - 1, _Max);
2867- auto&& _Alproxy = _GET_PROXY_ALLOCATOR(_Alty, _Getal());
2874+ auto _New_capacity = _Calculate_growth(_New_size, _BUF_SIZE - 1, _Max);
2875+ auto&& _Alproxy = _GET_PROXY_ALLOCATOR(_Alty, _Getal());
28682876 _Container_proxy_ptr<_Alty> _Proxy(_Alproxy, _My_data); // throws
2869- const pointer _Fancyptr = _Getal().allocate(_New_capacity + 1); // throws
2877+ ++_New_capacity;
2878+ const pointer _Fancyptr = _Allocate_at_least_helper(_Getal(), _New_capacity); // throws
2879+ --_New_capacity;
28702880 // nothrow hereafter
28712881 _Start_element_lifetimes(_Unfancy(_Fancyptr), _New_capacity + 1);
28722882 _Construct_in_place(_My_data._Bx._Ptr, _Fancyptr);
@@ -2946,9 +2956,10 @@ public:
29462956 _Result._Res = _My_data._Myres + 1;
29472957 } else {
29482958 // use _BUF_SIZE + 1 to avoid SSO, if the buffer is assigned back
2949- _Result._Ptr = _Al.allocate(_BUF_SIZE + 1);
2959+ size_type _Allocated = _BUF_SIZE + 1;
2960+ _Result._Ptr = _Allocate_at_least_helper(_Al, _Allocated);
29502961 _Traits::copy(_Unfancy(_Result._Ptr), _My_data._Bx._Buf, _BUF_SIZE);
2951- _Result._Res = _BUF_SIZE + 1 ;
2962+ _Result._Res = _Allocated ;
29522963 }
29532964 _My_data._Orphan_all();
29542965 _Tidy_init();
@@ -3167,9 +3178,11 @@ public:
31673178
31683179 if (_Right._Mypair._Myval2._Large_string_engaged()) {
31693180 const auto _New_size = _Right._Mypair._Myval2._Mysize;
3170- const auto _New_capacity = _Calculate_growth(_New_size, 0, _Right.max_size());
3181+ auto _New_capacity = _Calculate_growth(_New_size, 0, _Right.max_size());
31713182 auto _Right_al_non_const = _Right_al;
3172- const auto _New_ptr = _Right_al_non_const.allocate(_New_capacity + 1); // throws
3183+ ++_New_capacity;
3184+ const auto _New_ptr = _Allocate_at_least_helper(_Right_al_non_const, _New_capacity); // throws
3185+ --_New_capacity;
31733186
31743187 _Start_element_lifetimes(_Unfancy(_New_ptr), _New_capacity + 1);
31753188
@@ -4736,9 +4749,11 @@ private:
47364749 }
47374750
47384751 const size_type _Old_capacity = _Mypair._Myval2._Myres;
4739- const size_type _New_capacity = _Calculate_growth(_New_size);
4752+ size_type _New_capacity = _Calculate_growth(_New_size);
47404753 auto& _Al = _Getal();
4741- const pointer _New_ptr = _Al.allocate(_New_capacity + 1); // throws
4754+ ++_New_capacity;
4755+ const pointer _New_ptr = _Allocate_at_least_helper(_Al, _New_capacity); // throws
4756+ --_New_capacity;
47424757
47434758 _Start_element_lifetimes(_Unfancy(_New_ptr), _New_capacity + 1);
47444759 _Mypair._Myval2._Orphan_all();
@@ -4769,9 +4784,11 @@ private:
47694784
47704785 const size_type _New_size = _Old_size + _Size_increase;
47714786 const size_type _Old_capacity = _My_data._Myres;
4772- const size_type _New_capacity = _Calculate_growth(_New_size);
4787+ size_type _New_capacity = _Calculate_growth(_New_size);
47734788 auto& _Al = _Getal();
4774- const pointer _New_ptr = _Al.allocate(_New_capacity + 1); // throws
4789+ ++_New_capacity;
4790+ const pointer _New_ptr = _Allocate_at_least_helper(_Al, _New_capacity); // throws
4791+ --_New_capacity;
47754792
47764793 _Start_element_lifetimes(_Unfancy(_New_ptr), _New_capacity + 1);
47774794 _My_data._Orphan_all();
0 commit comments