FastLED 3.10.8
Loading...
Searching...
No Matches

◆ trivial_swap()

void fl::vector_basic::trivial_swap ( void * a,
void * b ) const
private

Definition at line 41 of file basic_vector.cpp.hpp.

41 {
42 // Stack buffer for small elements, heap for large
43 char stack_buf[64];
44 void* tmp;
45 bool heap_allocated = false;
46 if (mElementSize <= sizeof(stack_buf)) {
47 tmp = stack_buf;
48 } else {
49 tmp = mResource->allocate(mElementSize);
50 heap_allocated = true;
51 }
52 fl::memcpy(tmp, a, mElementSize);
54 fl::memcpy(b, tmp, mElementSize);
55 if (heap_allocated) {
56 mResource->deallocate(tmp, mElementSize);
57 }
58}
fl::size mElementSize
memory_resource * mResource
FASTLED_FORCE_INLINE void * memcpy(void *dest, const void *src, size_t n) FL_NO_EXCEPT
Definition cstring.h:136

References fl::FL_NO_EXCEPT, mElementSize, fl::memcpy(), and mResource.

Referenced by swap_impl().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: