| 410 | } |
| 411 | |
| 412 | static void |
| 413 | prof_recent_alloc_restore_locked(tsd_t *tsd, prof_recent_list_t *to_delete) { |
| 414 | malloc_mutex_assert_owner(tsd_tsdn(tsd), &prof_recent_alloc_mtx); |
| 415 | ssize_t max = prof_recent_alloc_max_get(tsd); |
| 416 | if (max == -1 || prof_recent_alloc_count <= max) { |
| 417 | /* Easy case - no need to alter the list. */ |
| 418 | ql_new(to_delete); |
| 419 | prof_recent_alloc_assert_count(tsd); |
| 420 | return; |
| 421 | } |
| 422 | |
| 423 | prof_recent_t *node; |
| 424 | ql_foreach(node, &prof_recent_alloc_list, link) { |
| 425 | if (prof_recent_alloc_count == max) { |
| 426 | break; |
| 427 | } |
| 428 | prof_recent_alloc_evict_edata(tsd, node); |
| 429 | --prof_recent_alloc_count; |
| 430 | } |
| 431 | assert(prof_recent_alloc_count == max); |
| 432 | |
| 433 | ql_move(to_delete, &prof_recent_alloc_list); |
| 434 | if (max == 0) { |
| 435 | assert(node == NULL); |
| 436 | } else { |
| 437 | assert(node != NULL); |
| 438 | ql_split(to_delete, node, &prof_recent_alloc_list, link); |
| 439 | } |
| 440 | assert(!ql_empty(to_delete)); |
| 441 | prof_recent_alloc_assert_count(tsd); |
| 442 | } |
| 443 | |
| 444 | static void |
| 445 | prof_recent_alloc_async_cleanup(tsd_t *tsd, prof_recent_list_t *to_delete) { |
no test coverage detected