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

◆ grow()

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

Definition at line 269 of file str.cpp.

269 {
270 if (newLength <= mCapacity) {
271 // New length must be greater than current length
272 mLength = newLength;
273 return;
274 }
275 char *newData = (char *)realloc(mData, newLength + 1);
276 if (newData) {
277 mData = newData;
278 mLength = newLength;
279 mCapacity = newLength;
280 mData[mLength] = '\0'; // Ensure null-termination
281 } else {
282 // handle re-allocation failure.
283 char *newData = (char *)malloc(newLength + 1);
284 if (newData) {
285 memcpy(newData, mData, mLength + 1);
286 free(mData);
287 mData = newData;
288 mLength = newLength;
290 } else {
291 // memory failure.
292 }
293 }
294}
char * mData
Definition str.h:133
fl::size mLength
Definition str.h:134
fl::size mCapacity
Definition str.h:135

References mCapacity, mData, and mLength.