MCPcopy Create free account
hub / github.com/FastLED/FastLED / reserve

Method reserve

src/fl/stl/basic_string.cpp.hpp:475–488  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

473// ======= MEMORY MANAGEMENT =======
474
475void basic_string::reserve(fl::size newCapacity) {
476 if (newCapacity <= mLength) return;
477 if (newCapacity + 1 <= mInlineCapacity) return;
478 if (hasHeapData()) {
479 const NotNullStringHolderPtr& heap = heapData();
480 if (heap.get().use_count() <= 1 && heap->hasCapacity(newCapacity)) {
481 return;
482 }
483 }
484 NotNullStringHolderPtr newData = NotNullStringHolderPtr(fl::make_shared<StringHolder>(newCapacity));
485 fl::memcpy(newData->data(), c_str(), mLength);
486 newData->data()[mLength] = '\0';
487 mStorage = newData;
488}
489
490void basic_string::clear(bool freeMemory) {
491 mLength = 0;

Callers

nothing calls this directly

Calls 5

hasCapacityMethod · 0.80
memcpyFunction · 0.50
use_countMethod · 0.45
getMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected