Allocate memory for n objects of type T
| 891 | |
| 892 | // Allocate memory for n objects of type T |
| 893 | T* allocate(fl::size n) FL_NOEXCEPT { |
| 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 | } |
| 929 | |
| 930 | // Deallocate memory for n objects of type T |
| 931 | void deallocate(T* p, fl::size n) FL_NOEXCEPT { |
nothing calls this directly
no test coverage detected