SpiecsEngine
 
Loading...
Searching...
No Matches

◆ Bytes()

size_t Spices::MemoryPool::Bytes ( size_t index)
static

Determine how much bytes freelist should process the memory block with given index.

Parameters
[in]indexfreelist index.
Returns
Returns bytes of freelist index.

Definition at line 134 of file MemoryPool.cpp.

135 {
136 static constexpr int group_array[4] = { 16, 56, 56, 56 };
137
138 // align up to 8 (8 - 128 B)
139 if (index < 16)
140 {
141 return 8 * (index + 1);
142 }
143
144 // align up to 16 (128B - 1024 B)
145 else if(index < 16 + 56)
146 {
147 return 16 * (index + 1 - group_array[0]) + 128;
148 }
149
150 // align up to 128 (1 - 8 KB)
151 else if (index < 16 + 56 + 56)
152 {
153 return 128 * (index + 1 - group_array[0] - group_array[1]) + 1024;
154 }
155
156 // align up to 1024 (8 - 64 KB)
157 else if (index < 16 + 56 + 56 + 56)
158 {
159 return 1024 * (index + 1 - group_array[0] - group_array[1] - group_array[2]) + 8 * 1024;
160 }
161
162 // align up to 8KB (64 - 256 KB)
163 else if (index < 16 + 56 + 56 + 56 + 24)
164 {
165 return 8 * 1024 * (index + 1 - group_array[0] - group_array[1] - group_array[2] - group_array[3]) + 64 * 1024;
166 }
167
168 else
169 {
170 SPICES_CORE_ERROR("Access invalid free_lits index")
171 return 8 * 1024;
172 }
173 }