Safe delete a heap without freeing any still allocated blocks in that heap.
| 402 | |
| 403 | // Safe delete a heap without freeing any still allocated blocks in that heap. |
| 404 | void mi_heap_delete(mi_heap_t* heap) |
| 405 | { |
| 406 | mi_assert(heap != NULL); |
| 407 | mi_assert(mi_heap_is_initialized(heap)); |
| 408 | mi_assert_expensive(mi_heap_is_valid(heap)); |
| 409 | if (heap==NULL || !mi_heap_is_initialized(heap)) return; |
| 410 | |
| 411 | if (!mi_heap_is_backing(heap)) { |
| 412 | // tranfer still used pages to the backing heap |
| 413 | mi_heap_absorb(heap->tld->heap_backing, heap); |
| 414 | } |
| 415 | else { |
| 416 | // the backing heap abandons its pages |
| 417 | _mi_heap_collect_abandon(heap); |
| 418 | } |
| 419 | mi_assert_internal(heap->page_count==0); |
| 420 | mi_heap_free(heap); |
| 421 | } |
| 422 | |
| 423 | mi_heap_t* mi_heap_set_default(mi_heap_t* heap) { |
| 424 | mi_assert(heap != NULL); |