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
893
of file
allocator.h
.
893
{
894
if
(
n
== 0) {
895
return
nullptr
;
896
}
897
898
// For large allocations (n > 1), use base allocator directly
899
if
(
n
> 1) {
900
T
*
ptr
=
mBaseAllocator
.allocate(
n
);
901
if
(
ptr
) {
902
mActiveAllocations
+=
n
;
903
}
904
return
ptr
;
905
}
906
907
// For single allocations, first try inlined memory
908
// Find first free inlined slot
909
fl::i32
free_slot
=
mFreeBits
.find_first(
false
);
910
if
(
free_slot
>= 0 &&
static_cast<
fl::size
>
(
free_slot
) <
N
) {
911
// Mark the inlined slot as used
912
mFreeBits
.set(
static_cast<
fl::u32
>
(
free_slot
),
true
);
913
914
// Update inlined usage tracking
915
if
(
static_cast<
fl::size
>
(
free_slot
) + 1 >
mInlinedUsed
) {
916
mInlinedUsed
=
static_cast<
fl::size
>
(
free_slot
) + 1;
917
}
918
mActiveAllocations
++;
919
return
&
get_inlined_ptr
()[
static_cast<
fl::size
>
(
free_slot
)];
920
}
921
922
// No inlined slots available, use heap allocation
923
T
*
ptr
=
mBaseAllocator
.allocate(1);
924
if
(
ptr
) {
925
mActiveAllocations
++;
926
}
927
return
ptr
;
928
}
fl::allocator_inlined::mBaseAllocator
BaseAllocator mBaseAllocator
Definition
allocator.h:818
fl::allocator_inlined::mActiveAllocations
fl::size mActiveAllocations
Definition
allocator.h:821
fl::allocator_inlined::mInlinedUsed
fl::size mInlinedUsed
Definition
allocator.h:819
fl::allocator_inlined::get_inlined_ptr
T * get_inlined_ptr() FL_NOEXCEPT
Definition
allocator.h:1001
fl::allocator_inlined::mFreeBits
fl::bitset_fixed< N > mFreeBits
Definition
allocator.h:820
fl::allocator_inlined
Definition
allocator.h:805
fl
allocator_inlined
Generated on Tue Jun 16 2026 00:07:04 for FastLED by
1.13.2