| 204 | } |
| 205 | |
| 206 | void _mi_page_free_collect(mi_page_t* page, bool force) { |
| 207 | mi_assert_internal(page!=NULL); |
| 208 | |
| 209 | // collect the thread free list |
| 210 | if (force || mi_page_thread_free(page) != NULL) { // quick test to avoid an atomic operation |
| 211 | _mi_page_thread_free_collect(page); |
| 212 | } |
| 213 | |
| 214 | // and the local free list |
| 215 | if (page->local_free != NULL) { |
| 216 | if mi_likely(page->free == NULL) { |
| 217 | // usual case |
| 218 | page->free = page->local_free; |
| 219 | page->local_free = NULL; |
| 220 | page->is_zero = false; |
| 221 | } |
| 222 | else if (force) { |
| 223 | // append -- only on shutdown (force) as this is a linear operation |
| 224 | mi_block_t* tail = page->local_free; |
| 225 | mi_block_t* next; |
| 226 | while ((next = mi_block_next(page, tail)) != NULL) { |
| 227 | tail = next; |
| 228 | } |
| 229 | mi_block_set_next(page, tail, page->free); |
| 230 | page->free = page->local_free; |
| 231 | page->local_free = NULL; |
| 232 | page->is_zero = false; |
| 233 | } |
| 234 | } |
| 235 | |
| 236 | mi_assert_internal(!force || page->local_free == NULL); |
| 237 | } |
| 238 | |
| 239 | |
| 240 |
no test coverage detected