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 366 of file allocator.h.

366 {
367 if (!ptr) {
368 return;
369 }
370
371 // Try to deallocate from slab first
372 bool found_in_slab = false;
373 for (Slab* slab = slabs_; slab; slab = slab->next) {
374 u8* slab_start = slab->memory;
376 u8* block_ptr = fl::bit_cast_ptr<u8>(static_cast<void*>(ptr));
377
380 found_in_slab = true;
381 break;
382 }
383 }
384
385 if (!found_in_slab) {
386 // This was allocated with regular malloc
387 free(ptr);
388 }
389 }
static constexpr fl::size SLAB_MEMORY_SIZE
Definition allocator.h:189
void deallocateToSlab(void *ptr, fl::size n=1)
Definition allocator.h:284
To * bit_cast_ptr(void *storage) noexcept
Definition bit_cast.h:54

References fl::bit_cast_ptr(), deallocateToSlab(), SLAB_MEMORY_SIZE, and slabs_.

+ Here is the call graph for this function: