FastLED 3.10.10
Loading...
Searching...
No Matches

◆ resize() [2/2]

void fl::basic_string::resize ( fl::size count,
char ch )

Definition at line 1486 of file basic_string.cpp.hpp.

1486 {
1487 if (count < mLength) {
1488 mLength = count;
1489 c_str_mutable()[mLength] = '\0';
1490 } else if (count > mLength) {
1491 fl::size additional_chars = count - mLength;
1492 reserve(count);
1493 char* data_ptr = c_str_mutable();
1494 // Materialize literal/view storage before checking its writable space.
1495 // A failed heap growth must leave the existing bytes and length intact.
1496 if (capacity() <= count) { return; }
1497 for (fl::size i = 0; i < additional_chars; ++i) {
1498 data_ptr[mLength + i] = ch;
1499 }
1500 mLength = count;
1501 data_ptr[mLength] = '\0';
1502 }
1503}
char * c_str_mutable() FL_NO_EXCEPT
void reserve(fl::size newCapacity) FL_NO_EXCEPT
fl::size capacity() const FL_NO_EXCEPT

References c_str_mutable(), capacity(), fl::FL_NO_EXCEPT, mLength, and reserve().

+ Here is the call graph for this function: