| 177 return ptr; // LCOV_EXCL_LINE |
177 return ptr; // LCOV_EXCL_LINE |
| 178 } |
178 } |
| 179 } |
179 } |
| 180 |
180 |
| 181 static void cx_mempool_free_all_simple(const struct cx_mempool_s *pool) { |
181 static void cx_mempool_free_all_simple(const struct cx_mempool_s *pool) { |
| 182 const bool has_destr = pool->destr; |
|
| 183 const bool has_destr2 = pool->destr2; |
|
| 184 for (size_t i = 0; i < pool->size; i++) { |
182 for (size_t i = 0; i < pool->size; i++) { |
| 185 struct cx_mempool_memory_s *mem = pool->data[i]; |
183 struct cx_mempool_memory_s *mem = pool->data[i]; |
| 186 if (mem->destructor) { |
184 if (mem->destructor) { |
| 187 mem->destructor(mem->c); |
185 mem->destructor(mem->c); |
| 188 } |
186 } |
| 189 if (has_destr) { |
187 if (pool->destr != NULL) { |
| 190 pool->destr(mem->c); |
188 pool->destr(mem->c); |
| 191 } |
189 } |
| 192 if (has_destr2) { |
190 if (pool->destr2 != NULL) { |
| 193 pool->destr2(pool->destr2_data, mem->c); |
191 pool->destr2(pool->destr2_data, mem->c); |
| 194 } |
192 } |
| 195 cxFree(pool->base_allocator, mem); |
193 cxFree(pool->base_allocator, mem); |
| 196 } |
194 } |
| 197 } |
195 } |