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

Method deallocate

src/fl/stl/allocator.h:641–664  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

639 }
640
641 void deallocate(T* ptr, fl::size n = 1) FL_NOEXCEPT {
642 if (!ptr) {
643 return;
644 }
645
646 // Try to deallocate from slab first
647 bool found_in_slab = false;
648 for (Slab* slab = mSlabs; slab; slab = slab->next) {
649 u8* slab_start = slab->memory;
650 u8* slab_end = slab_start + SLAB_MEMORY_SIZE;
651 u8* block_ptr = fl::bit_cast_ptr<u8>(static_cast<void*>(ptr));
652
653 if (block_ptr >= slab_start && block_ptr < slab_end) {
654 deallocateToSlab(ptr, n);
655 found_in_slab = true;
656 break;
657 }
658 }
659
660 if (!found_in_slab) {
661 // This was allocated with regular malloc
662 Free(ptr);
663 }
664 }
665
666 // Get allocation statistics
667 fl::size getTotalAllocated() const FL_NOEXCEPT { return mTotalAllocated; }

Callers

nothing calls this directly

Calls 1

FreeFunction · 0.85

Tested by

no test coverage detected