| 941 | static const unsigned TOP_LIMIT = 1024; // TINY_BLOCK_LIMIT |
| 942 | |
| 943 | static unsigned getSlot(size_t size, GetSlotFor mode) |
| 944 | { |
| 945 | // add 2 asserts as long as we have not found better way to declare consts |
| 946 | fb_assert(TOTAL_ELEMENTS == TINY_SLOTS); |
| 947 | fb_assert(TOP_LIMIT == *TINY_BLOCK_LIMIT); |
| 948 | |
| 949 | const size_t LOW_LIMIT = lowLimits[0]; |
| 950 | fb_assert(size <= TOP_LIMIT); |
| 951 | if (size < LOW_LIMIT) |
| 952 | size = LOW_LIMIT; |
| 953 | fb_assert(MEM_ALIGN(size) == size); |
| 954 | |
| 955 | unsigned slot = lowSlots[(size - LOW_LIMIT) >> SLOT_SHIFT]; |
| 956 | fb_assert(size <= lowLimits[slot]); |
| 957 | if (lowLimits[slot] > size && mode == SLOT_FREE) |
| 958 | { |
| 959 | if (!slot) |
| 960 | return ~0; |
| 961 | --slot; |
| 962 | } |
| 963 | |
| 964 | return slot; |
| 965 | } |
| 966 | |
| 967 | static unsigned getSize(unsigned slot) |
| 968 | { |
nothing calls this directly
no test coverage detected