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

◆ reserve()

template<size_t SIZE = 64>
void fl::StrN< SIZE >::reserve ( size_t newCapacity)
inline

Definition at line 308 of file str.h.

308 {
309 // If capacity is less than current length, do nothing
310 if (newCapacity <= mLength) {
311 return;
312 }
313
314 // If new capacity fits in inline buffer, no need to allocate
315 if (newCapacity + 1 <= SIZE) {
316 return;
317 }
318
319 // If we already have unshared heap data with sufficient capacity, do
320 // nothing
321 if (mHeapData && !mHeapData->isShared() &&
322 mHeapData->hasCapacity(newCapacity)) {
323 return;
324 }
325
326 // Need to allocate new storage
328 if (newData) {
329 // Copy existing content
330 memcpy(newData->data(), c_str(), mLength);
331 newData->data()[mLength] = '\0';
333 }
334 }
size_t mLength
Definition str.h:108
const char * c_str() const
Definition str.h:272
StringHolderPtr mHeapData
Definition str.h:110

References c_str(), mHeapData, and mLength.

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

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