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

◆ write() [2/8]

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

Definition at line 204 of file str.h.

204 {
205 size_t newLen = mLength + n;
206 if (mHeapData && !mHeapData->isShared()) {
207 if (!mHeapData->hasCapacity(newLen)) {
208 size_t grow_length = MAX(3, newLen * 3 / 2);
209 mHeapData->grow(grow_length); // Grow by 50%
210 }
211 memcpy(mHeapData->data() + mLength, str, n);
212 mLength = newLen;
213 mHeapData->data()[mLength] = '\0';
214 return mLength;
215 }
216 if (newLen + 1 <= SIZE) {
218 mLength = newLen;
219 mInlineData[mLength] = '\0';
220 return mLength;
221 }
222 mHeapData.reset();
224 if (newData) {
225 memcpy(newData->data(), c_str(), mLength);
226 memcpy(newData->data() + mLength, str, n);
227 newData->data()[newLen] = '\0';
229 mLength = newLen;
230 }
232 return mLength;
233 }
size_t mLength
Definition str.h:109
const char * c_str() const
Definition str.h:273
StringHolderPtr mHeapData
Definition str.h:111
char mInlineData[SIZE]
Definition str.h:110
#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: