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

◆ deallocate()

template<typename T, fl::size SLAB_SIZE = FASTLED_DEFAULT_SLAB_SIZE>
void fl::SlabAllocator< T, SLAB_SIZE >::deallocate ( T * ptr,
fl::size n = 1 )
inline

Definition at line 641 of file allocator.h.

641 {
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;
651 u8* block_ptr = fl::bit_cast_ptr<u8>(static_cast<void*>(ptr));
652
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 }
static constexpr fl::size SLAB_MEMORY_SIZE
Definition allocator.h:466
void deallocateToSlab(void *ptr, fl::size n=1) FL_NOEXCEPT
Definition allocator.h:559
void Free(void *ptr)
To * bit_cast_ptr(void *storage) FL_NOEXCEPT
Definition bit_cast.h:60

References fl::bit_cast_ptr(), deallocateToSlab(), FL_NOEXCEPT, fl::Free(), mSlabs, and SLAB_MEMORY_SIZE.

+ Here is the call graph for this function: