FastLED 3.10.6
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 653 of file allocator.h.

653 {
654 if (!ptr) {
655 return;
656 }
657 fl::detail::slab_lock_guard guard(mMutex); // see allocate()
658
659 // Try to deallocate from slab first
660 bool found_in_slab = false;
661 for (Slab* slab = mSlabs; slab; slab = slab->next) {
662 u8* slab_start = slab->memory;
664 u8* block_ptr = fl::bit_cast_ptr<u8>(static_cast<void*>(ptr));
665
668 found_in_slab = true;
669 break;
670 }
671 }
672
673 if (!found_in_slab) {
674 // This was allocated with regular malloc
675 Free(ptr);
676 }
677 }
static constexpr fl::size SLAB_MEMORY_SIZE
Definition allocator.h:467
fl::detail::slab_mutex mMutex
Definition allocator.h:487
void deallocateToSlab(void *ptr, fl::size n=1) FL_NO_EXCEPT
Definition allocator.h:563
void Free(void *ptr)
To * bit_cast_ptr(void *storage) FL_NO_EXCEPT
Definition bit_cast.h:60

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

+ Here is the call graph for this function: