FastLED 3.10.6
Loading...
Searching...
No Matches

◆ findContiguousBlocks()

template<typename T, fl::size SLAB_SIZE = FASTLED_DEFAULT_SLAB_SIZE>
void * fl::SlabAllocator< T, SLAB_SIZE >::findContiguousBlocks ( Slab * slab,
fl::size n )
inlineprivate

Definition at line 540 of file allocator.h.

540 {
541 // Check if allocation is too large for this slab
542 if (n > BLOCKS_PER_SLAB) {
543 return nullptr;
544 }
545
546 // Use bitset's find_run to find n contiguous free blocks (false = free)
547 fl::i32 start = slab->allocated_blocks.find_run(false, static_cast<fl::u32>(n));
548 if (start >= 0) {
549 // Mark blocks as allocated
550 for (fl::size i = 0; i < n; ++i) {
551 slab->allocated_blocks.set(static_cast<fl::u32>(start + i), true);
552 }
553 slab->allocated_count += n;
555
556 // Return pointer to the first block
557 return slab->memory + static_cast<fl::size>(start) * SLAB_BLOCK_SIZE;
558 }
559
560 return nullptr;
561 }
static constexpr fl::size BLOCKS_PER_SLAB
Definition allocator.h:466
static constexpr fl::size SLAB_BLOCK_SIZE
Definition allocator.h:465
fl::size mTotalAllocated
Definition allocator.h:488

References BLOCKS_PER_SLAB, fl::FL_NO_EXCEPT, mTotalAllocated, and SLAB_BLOCK_SIZE.

Referenced by allocateFromSlab().

+ Here is the caller graph for this function: