MCPcopy Create free account
hub / github.com/ablab/spades / grow

Method grow

ext/include/cppformat/format.h:360–376  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

358
359template <typename T, std::size_t SIZE, typename Allocator>
360void MemoryBuffer<T, SIZE, Allocator>::grow(std::size_t size) {
361 std::size_t new_capacity =
362 (std::max)(size, this->capacity_ + this->capacity_ / 2);
363 T *new_ptr = this->allocate(new_capacity);
364 // The following code doesn't throw, so the raw pointer above doesn't leak.
365 std::copy(this->ptr_,
366 this->ptr_ + this->size_, make_ptr(new_ptr, new_capacity));
367 std::size_t old_capacity = this->capacity_;
368 T *old_ptr = this->ptr_;
369 this->capacity_ = new_capacity;
370 this->ptr_ = new_ptr;
371 // deallocate may throw (at least in principle), but it doesn't matter since
372 // the buffer already uses the new storage and will deallocate it in case
373 // of exception.
374 if (old_ptr != data_)
375 this->deallocate(old_ptr, old_capacity);
376}
377
378#ifndef _MSC_VER
379// Portable version of signbit.

Callers

nothing calls this directly

Calls 4

make_ptrFunction · 0.85
copyFunction · 0.50
allocateMethod · 0.45
deallocateMethod · 0.45

Tested by

no test coverage detected