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

◆ write() [2/9]

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

Definition at line 251 of file str.h.

251 {
253 if (mHeapData && mHeapData.use_count() <= 1) {
254 if (!mHeapData->hasCapacity(newLen)) {
255 fl::size grow_length = MAX(3, newLen * 3 / 2);
256 mHeapData->grow(grow_length); // Grow by 50%
257 }
258 memcpy(mHeapData->data() + mLength, str, n);
259 mLength = newLen;
260 mHeapData->data()[mLength] = '\0';
261 return mLength;
262 }
263 if (newLen + 1 <= SIZE) {
265 mLength = newLen;
266 mInlineData[mLength] = '\0';
267 return mLength;
268 }
269 mHeapData.reset();
271 if (newData) {
272 memcpy(newData->data(), c_str(), mLength);
273 memcpy(newData->data() + mLength, str, n);
274 newData->data()[newLen] = '\0';
276 mLength = newLen;
277 }
279 return mLength;
280 }
const char * c_str() const
Definition str.h:326
StringHolderPtr mHeapData
Definition str.h:142
char mInlineData[SIZE]
Definition str.h:141
fl::size mLength
Definition str.h:140
#define MAX(a, b)
Definition math_macros.h:37
shared_ptr< T > make_shared(Args &&... args)
Definition shared_ptr.h:348

References c_str(), fl::make_shared(), MAX, mHeapData, mInlineData, and mLength.

+ Here is the call graph for this function: