LWG-3120 Unclear behavior of monotonic_buffer_resource::release()
This adds the following Standardese:
Effects: Calls upstream_rsrc->deallocate() as necessary to release all allocated memory. Resets current_buffer and next_buffer_size to their initial values at construction.
Our current implementation doesn't appear to do that:
|
void release() noexcept /* strengthened */ {
|
|
if (_Chunks._Empty()) {
|
|
// nothing to release; potentially continues to use an initial block provided at construction
|
|
return;
|
|
}
|
|
|
|
_Current_buffer = nullptr;
|
|
_Space_available = 0;
|
|
|
|
// unscale _Next_buffer_size so the next allocation will be the same size as the most recent allocation
|
|
// (keep synchronized with monotonic_buffer_resource::_Scale)
|
|
const size_t _Unscaled = (_Next_buffer_size / 3 * 2 + alignof(_Header) - 1) & _Max_allocation;
|
|
_Next_buffer_size = (_STD max)(_Unscaled, _Min_allocation);
|
|
|
|
_Intrusive_stack<_Header> _Tmp{};
|
|
_STD swap(_Tmp, _Chunks);
|
|
while (!_Tmp._Empty()) {
|
|
const auto _Ptr = _Tmp._Pop();
|
|
_Resource->deallocate(_Ptr->_Base_address(), _Ptr->_Size, _Ptr->_Align);
|
|
}
|
|
}
|
LWG-3120 Unclear behavior of
monotonic_buffer_resource::release()This adds the following Standardese:
Our current implementation doesn't appear to do that:
STL/stl/inc/memory_resource
Lines 636 to 656 in 9959929