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 309 of file str.h.

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

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: