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

284 {
285 // If capacity is less than current length, do nothing
286 if (newCapacity <= mLength) {
287 return;
288 }
289
290 // If new capacity fits in inline buffer, no need to allocate
291 if (newCapacity + 1 <= SIZE) {
292 return;
293 }
294
295 // If we already have unshared heap data with sufficient capacity, do nothing
296 if (mHeapData && !mHeapData->isShared() && mHeapData->hasCapacity(newCapacity)) {
297 return;
298 }
299
300 // Need to allocate new storage
302 if (newData) {
303 // Copy existing content
304 memcpy(newData->data(), c_str(), mLength);
305 newData->data()[mLength] = '\0';
307 }
308 }
size_t mLength
Definition str.h:81
const char * c_str() const
Definition str.h:247
StringHolderPtr mHeapData
Definition str.h:83
Definition str.h:79

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: