| 648 | } |
| 649 | |
| 650 | bool |
| 651 | tcaches_create(tsd_t *tsd, unsigned *r_ind) { |
| 652 | witness_assert_depth(tsdn_witness_tsdp_get(tsd_tsdn(tsd)), 0); |
| 653 | |
| 654 | bool err; |
| 655 | |
| 656 | if (tcaches_create_prep(tsd)) { |
| 657 | err = true; |
| 658 | goto label_return; |
| 659 | } |
| 660 | |
| 661 | tcache_t *tcache = tcache_create_explicit(tsd); |
| 662 | if (tcache == NULL) { |
| 663 | err = true; |
| 664 | goto label_return; |
| 665 | } |
| 666 | |
| 667 | tcaches_t *elm; |
| 668 | malloc_mutex_lock(tsd_tsdn(tsd), &tcaches_mtx); |
| 669 | if (tcaches_avail != NULL) { |
| 670 | elm = tcaches_avail; |
| 671 | tcaches_avail = tcaches_avail->next; |
| 672 | elm->tcache = tcache; |
| 673 | *r_ind = (unsigned)(elm - tcaches); |
| 674 | } else { |
| 675 | elm = &tcaches[tcaches_past]; |
| 676 | elm->tcache = tcache; |
| 677 | *r_ind = tcaches_past; |
| 678 | tcaches_past++; |
| 679 | } |
| 680 | malloc_mutex_unlock(tsd_tsdn(tsd), &tcaches_mtx); |
| 681 | |
| 682 | err = false; |
| 683 | label_return: |
| 684 | witness_assert_depth(tsdn_witness_tsdp_get(tsd_tsdn(tsd)), 0); |
| 685 | return err; |
| 686 | } |
| 687 | |
| 688 | static tcache_t * |
| 689 | tcaches_elm_remove(tsd_t *tsd, tcaches_t *elm, bool allow_reinit) { |
no test coverage detected