-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Open
Labels
LWGLibrary Working Group issueLibrary Working Group issuevNextBreaks binary compatibilityBreaks binary compatibility
Description
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. Resetscurrent_buffer
andnext_buffer_size
to their initial values at construction.
Our current implementation doesn't appear to do that:
Lines 636 to 656 in 9959929
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); | |
} | |
} |
Metadata
Metadata
Assignees
Labels
LWGLibrary Working Group issueLibrary Working Group issuevNextBreaks binary compatibilityBreaks binary compatibility
Type
Projects
Status
Blocked