| 99 | |
| 100 | public: |
| 101 | void* alloc(size_t size) { |
| 102 | auto idx = get_slot(size); |
| 103 | if (unlikely(idx >= N_SLOTS)) { |
| 104 | // larger than biggest slot |
| 105 | return __alloc(size); |
| 106 | } |
| 107 | auto ptr = slots[idx].get(); |
| 108 | // got from pool |
| 109 | if (ptr) { |
| 110 | in_pool_size -= slots[idx].slotsize; |
| 111 | return ptr; |
| 112 | } |
| 113 | return __alloc(slots[idx].slotsize); |
| 114 | } |
| 115 | int dealloc(void* ptr, size_t size) { |
| 116 | auto idx = get_slot(size); |
| 117 | if (unlikely(idx >= N_SLOTS || |
no test coverage detected