FastLED
3.9.15
Loading...
Searching...
No Matches
◆
allocate()
template<typename T, fl::size N, typename BaseAllocator = fl::allocator<T>>
T *
fl::allocator_inlined
< T, N, BaseAllocator >::allocate
(
fl::size
n
)
inline
Definition at line
609
of file
allocator.h
.
609
{
610
if
(
n
== 0) {
611
return
nullptr
;
612
}
613
614
// For large allocations (n > 1), use base allocator directly
615
if
(
n
> 1) {
616
T
*
ptr
=
m_base_allocator
.allocate(
n
);
617
if
(
ptr
) {
618
m_active_allocations
+=
n
;
619
}
620
return
ptr
;
621
}
622
623
// For single allocations, first try inlined memory
624
// Find first free inlined slot
625
fl::i32
free_slot
=
m_free_bits
.find_first(
false
);
626
if
(
free_slot
>= 0 &&
static_cast<
fl::size
>
(
free_slot
) <
N
) {
627
// Mark the inlined slot as used
628
m_free_bits
.set(
static_cast<
fl::u32
>
(
free_slot
),
true
);
629
630
// Update inlined usage tracking
631
if
(
static_cast<
fl::size
>
(
free_slot
) + 1 >
m_inlined_used
) {
632
m_inlined_used
=
static_cast<
fl::size
>
(
free_slot
) + 1;
633
}
634
m_active_allocations
++;
635
return
&
get_inlined_ptr
()[
static_cast<
fl::size
>
(
free_slot
)];
636
}
637
638
// No inlined slots available, use heap allocation
639
T
*
ptr
=
m_base_allocator
.allocate(1);
640
if
(
ptr
) {
641
m_active_allocations
++;
642
}
643
return
ptr
;
644
}
fl::allocator_inlined::m_base_allocator
BaseAllocator m_base_allocator
Definition
allocator.h:534
fl::allocator_inlined::get_inlined_ptr
T * get_inlined_ptr()
Definition
allocator.h:719
fl::allocator_inlined::m_free_bits
fl::bitset_fixed< N > m_free_bits
Definition
allocator.h:536
fl::allocator_inlined::m_active_allocations
fl::size m_active_allocations
Definition
allocator.h:537
fl::allocator_inlined::m_inlined_used
fl::size m_inlined_used
Definition
allocator.h:535
fl::allocator_inlined
Definition
allocator.h:521
fl
allocator_inlined
Generated on Fri Aug 22 2025 20:59:36 for FastLED by
1.13.2