MCPcopy Create free account
hub / github.com/ObEngine/ObEngine / grow

Method grow

extlibs/fmt/include/fmt/format.h:700–717  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

698
699template <typename T, std::size_t SIZE, typename Allocator>
700void basic_memory_buffer<T, SIZE, Allocator>::grow(std::size_t size) {
701#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
702 if (size > 1000) throw std::runtime_error("fuzz mode - won't grow that much");
703#endif
704 std::size_t old_capacity = this->capacity();
705 std::size_t new_capacity = old_capacity + old_capacity / 2;
706 if (size > new_capacity) new_capacity = size;
707 T* old_data = this->data();
708 T* new_data = std::allocator_traits<Allocator>::allocate(*this, new_capacity);
709 // The following code doesn't throw, so the raw pointer above doesn't leak.
710 std::uninitialized_copy(old_data, old_data + this->size(),
711 internal::make_checked(new_data, new_capacity));
712 this->set(new_data, new_capacity);
713 // deallocate must not throw according to the standard, but even if it does,
714 // the buffer already uses the new storage and will deallocate it in
715 // destructor.
716 if (old_data != store_) Allocator::deallocate(old_data, old_capacity);
717}
718
719using memory_buffer = basic_memory_buffer<char>;
720using wmemory_buffer = basic_memory_buffer<wchar_t>;

Callers

nothing calls this directly

Calls 5

make_checkedFunction · 0.85
capacityMethod · 0.80
dataMethod · 0.45
sizeMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected