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

◆ resize() [2/2]

void fl::string::resize ( fl::size count,
char ch )
inline

Definition at line 919 of file str.h.

919 {
920 if (count < mLength) {
921 // Truncate the string
922 mLength = count;
923 c_str_mutable()[mLength] = '\0';
924 } else if (count > mLength) {
925 // Extend the string with the specified character
926 fl::size additional_chars = count - mLength;
927 reserve(count); // Ensure enough capacity
928 char* data_ptr = c_str_mutable();
929 for (fl::size i = 0; i < additional_chars; ++i) {
930 data_ptr[mLength + i] = ch;
931 }
932 mLength = count;
933 data_ptr[mLength] = '\0';
934 }
935 // If count == mLength, do nothing
936 }
void reserve(fl::size newCapacity)
Definition str.h:370

References fl::StrN< FASTLED_STR_INLINED_SIZE >::c_str_mutable(), fl::StrN< FASTLED_STR_INLINED_SIZE >::mLength, and fl::StrN< FASTLED_STR_INLINED_SIZE >::reserve().

+ Here is the call graph for this function: