FastLED 3.9.15
Loading...
Searching...
No Matches

◆ reserve()

template<fl::size SIZE = FASTLED_STR_INLINED_SIZE>
void fl::StrN< SIZE >::reserve ( fl::size newCapacity)
inline

Definition at line 370 of file str.h.

370 {
371 // If capacity is less than current length, do nothing
372 if (newCapacity <= mLength) {
373 return;
374 }
375
376 // If new capacity fits in inline buffer, no need to allocate
377 if (newCapacity + 1 <= SIZE) {
378 return;
379 }
380
381 // If we already have unshared heap data with sufficient capacity, do
382 // nothing
383 if (mHeapData && mHeapData.use_count() <= 1 &&
384 mHeapData->hasCapacity(newCapacity)) {
385 return;
386 }
387
388 // Need to allocate new storage
390 if (newData) {
391 // Copy existing content
392 memcpy(newData->data(), c_str(), mLength);
393 newData->data()[mLength] = '\0';
395 }
396 }
const char * c_str() const
Definition str.h:326
StringHolderPtr mHeapData
Definition str.h:142
fl::size mLength
Definition str.h:140
shared_ptr< T > make_shared(Args &&... args)
Definition shared_ptr.h:348

References c_str(), fl::make_shared(), mHeapData, and mLength.

Referenced by fl::FileSystem::readText().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: