FastLED 3.9.15
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages

◆ write() [2/8]

template<size_t SIZE = 64>
size_t fl::StrN< SIZE >::write ( const char * str,
size_t n )
inline

Definition at line 203 of file str.h.

203 {
204 size_t newLen = mLength + n;
205 if (mHeapData && !mHeapData->isShared()) {
206 if (!mHeapData->hasCapacity(newLen)) {
207 size_t grow_length = MAX(3, newLen * 3 / 2);
208 mHeapData->grow(grow_length); // Grow by 50%
209 }
210 memcpy(mHeapData->data() + mLength, str, n);
211 mLength = newLen;
212 mHeapData->data()[mLength] = '\0';
213 return mLength;
214 }
215 if (newLen + 1 <= SIZE) {
217 mLength = newLen;
218 mInlineData[mLength] = '\0';
219 return mLength;
220 }
221 mHeapData.reset();
223 if (newData) {
224 memcpy(newData->data(), c_str(), mLength);
225 memcpy(newData->data() + mLength, str, n);
226 newData->data()[newLen] = '\0';
228 mLength = newLen;
229 }
231 return mLength;
232 }
size_t mLength
Definition str.h:108
const char * c_str() const
Definition str.h:272
StringHolderPtr mHeapData
Definition str.h:110
char mInlineData[SIZE]
Definition str.h:109
#define MAX(a, b)
Definition math_macros.h:11

References c_str(), MAX, mHeapData, mInlineData, and mLength.

+ Here is the call graph for this function: