117 struct cx_mempool_s *pool = p; |
117 struct cx_mempool_s *pool = p; |
118 |
118 |
119 struct cx_mempool_memory_s *mem = (struct cx_mempool_memory_s *) |
119 struct cx_mempool_memory_s *mem = (struct cx_mempool_memory_s *) |
120 ((char *) ptr - sizeof(cx_destructor_func)); |
120 ((char *) ptr - sizeof(cx_destructor_func)); |
121 |
121 |
122 cx_for_n(i, pool->size) { |
122 for (size_t i = 0; i < pool->size; i++) { |
123 if (mem == pool->data[i]) { |
123 if (mem == pool->data[i]) { |
124 if (mem->destructor) { |
124 if (mem->destructor) { |
125 mem->destructor(mem->c); |
125 mem->destructor(mem->c); |
126 } |
126 } |
127 free(mem); |
127 free(mem); |
137 abort(); |
137 abort(); |
138 } |
138 } |
139 |
139 |
140 void cxMempoolDestroy(CxMempool *pool) { |
140 void cxMempoolDestroy(CxMempool *pool) { |
141 struct cx_mempool_memory_s *mem; |
141 struct cx_mempool_memory_s *mem; |
142 cx_for_n(i, pool->size) { |
142 for (size_t i = 0; i < pool->size; i++) { |
143 mem = pool->data[i]; |
143 mem = pool->data[i]; |
144 if (mem->destructor) { |
144 if (mem->destructor) { |
145 mem->destructor(mem->c); |
145 mem->destructor(mem->c); |
146 } |
146 } |
147 free(mem); |
147 free(mem); |