MCPcopy Create free account
hub / github.com/FastLED/FastLED / findContiguousBlocks

Method findContiguousBlocks

src/fl/stl/allocator.h:536–557  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

534 }
535
536 void* findContiguousBlocks(Slab* slab, fl::size n) FL_NOEXCEPT {
537 // Check if allocation is too large for this slab
538 if (n > BLOCKS_PER_SLAB) {
539 return nullptr;
540 }
541
542 // Use bitset's find_run to find n contiguous free blocks (false = free)
543 fl::i32 start = slab->allocated_blocks.find_run(false, static_cast<fl::u32>(n));
544 if (start >= 0) {
545 // Mark blocks as allocated
546 for (fl::size i = 0; i < n; ++i) {
547 slab->allocated_blocks.set(static_cast<fl::u32>(start + i), true);
548 }
549 slab->allocated_count += n;
550 mTotalAllocated += n;
551
552 // Return pointer to the first block
553 return slab->memory + static_cast<fl::size>(start) * SLAB_BLOCK_SIZE;
554 }
555
556 return nullptr;
557 }
558
559 void deallocateToSlab(void* ptr, fl::size n = 1) FL_NOEXCEPT {
560 if (!ptr) {

Callers

nothing calls this directly

Calls 2

find_runMethod · 0.80
setMethod · 0.45

Tested by

no test coverage detected