FastLED
3.10.6
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
907
of file
allocator.h
.
907
{
908
if
(
n
== 0) {
909
return
nullptr
;
910
}
911
912
// For large allocations (n > 1), use base allocator directly
913
if
(
n
> 1) {
914
T
*
ptr
=
mBaseAllocator
.allocate(
n
);
915
if
(
ptr
) {
916
mActiveAllocations
+=
n
;
917
}
918
return
ptr
;
919
}
920
921
// For single allocations, first try inlined memory
922
// Find first free inlined slot
923
fl::i32
free_slot
=
mFreeBits
.find_first(
false
);
924
if
(
free_slot
>= 0 &&
static_cast<
fl::size
>
(
free_slot
) <
N
) {
925
// Mark the inlined slot as used
926
mFreeBits
.set(
static_cast<
fl::u32
>
(
free_slot
),
true
);
927
928
// Update inlined usage tracking
929
if
(
static_cast<
fl::size
>
(
free_slot
) + 1 >
mInlinedUsed
) {
930
mInlinedUsed
=
static_cast<
fl::size
>
(
free_slot
) + 1;
931
}
932
mActiveAllocations
++;
933
return
&
get_inlined_ptr
()[
static_cast<
fl::size
>
(
free_slot
)];
934
}
935
936
// No inlined slots available, use heap allocation
937
T
*
ptr
=
mBaseAllocator
.allocate(1);
938
if
(
ptr
) {
939
mActiveAllocations
++;
940
}
941
return
ptr
;
942
}
fl::allocator_inlined::mBaseAllocator
BaseAllocator mBaseAllocator
Definition
allocator.h:832
fl::allocator_inlined::mActiveAllocations
fl::size mActiveAllocations
Definition
allocator.h:835
fl::allocator_inlined::get_inlined_ptr
T * get_inlined_ptr() FL_NO_EXCEPT
Definition
allocator.h:1015
fl::allocator_inlined::mInlinedUsed
fl::size mInlinedUsed
Definition
allocator.h:833
fl::allocator_inlined::mFreeBits
fl::bitset_fixed< N > mFreeBits
Definition
allocator.h:834
fl::allocator_inlined
Definition
allocator.h:819
fl
allocator_inlined
Generated on Sun Oct 4 2026 23:09:08 for FastLED by
1.13.2