FastLED 3.10.6
Loading...
Searching...
No Matches

◆ grow()

void fl::StringHolder::grow ( size newLength)

Definition at line 66 of file string_holder.cpp.hpp.

66 {
67 if (newLength + 1 <= mCapacity) {
68 // We have enough capacity for newLength + null terminator
69 mLength = newLength;
70 mData[mLength] = '\0';
71 return;
72 }
73
74 // Use fl::realloc for efficient growth without memory move.
75 // Keep the old buffer if the allocation fails — the string simply
76 // does not grow (callers observe the unchanged length).
77 char *grown = (char*)fl::realloc(mData, newLength + 1);
78 if (grown == nullptr) {
79 return;
80 }
81 mData = grown;
82 mLength = newLength;
83 mCapacity = newLength + 1;
84 mData[mLength] = '\0'; // Ensure null-termination
85}
void * realloc(void *ptr, size_t new_size)

References mCapacity, mData, mLength, and fl::realloc().

Referenced by operator=().

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