Allocator::max_size support in basic_memory_buffer (#1960)
This commit is contained in:
@@ -742,9 +742,11 @@ void basic_memory_buffer<T, SIZE, Allocator>::grow(size_t size) {
|
||||
#ifdef FMT_FUZZ
|
||||
if (size > 5000) throw std::runtime_error("fuzz mode - won't grow that much");
|
||||
#endif
|
||||
const size_t max_size = std::allocator_traits<Allocator>::max_size(alloc_);
|
||||
size_t old_capacity = this->capacity();
|
||||
size_t new_capacity = old_capacity + old_capacity / 2;
|
||||
if (size > new_capacity) new_capacity = size;
|
||||
else if (new_capacity > max_size) new_capacity = (std::max)(size, max_size);
|
||||
T* old_data = this->data();
|
||||
T* new_data =
|
||||
std::allocator_traits<Allocator>::allocate(alloc_, new_capacity);
|
||||
|
||||
Reference in New Issue
Block a user