| 2777 | } |
| 2778 | |
| 2779 | JEMALLOC_ALWAYS_INLINE size_t |
| 2780 | ixallocx_prof(tsd_t *tsd, void *ptr, size_t old_usize, size_t size, |
| 2781 | size_t extra, size_t alignment, bool zero, alloc_ctx_t *alloc_ctx) { |
| 2782 | size_t usize_max, usize; |
| 2783 | bool prof_active; |
| 2784 | prof_tctx_t *old_tctx, *tctx; |
| 2785 | |
| 2786 | prof_active = prof_active_get_unlocked(); |
| 2787 | old_tctx = prof_tctx_get(tsd_tsdn(tsd), ptr, alloc_ctx); |
| 2788 | /* |
| 2789 | * usize isn't knowable before ixalloc() returns when extra is non-zero. |
| 2790 | * Therefore, compute its maximum possible value and use that in |
| 2791 | * prof_alloc_prep() to decide whether to capture a backtrace. |
| 2792 | * prof_realloc() will use the actual usize to decide whether to sample. |
| 2793 | */ |
| 2794 | if (alignment == 0) { |
| 2795 | usize_max = sz_s2u(size+extra); |
| 2796 | assert(usize_max > 0 && usize_max <= LARGE_MAXCLASS); |
| 2797 | } else { |
| 2798 | usize_max = sz_sa2u(size+extra, alignment); |
| 2799 | if (unlikely(usize_max == 0 || usize_max > LARGE_MAXCLASS)) { |
| 2800 | /* |
| 2801 | * usize_max is out of range, and chances are that |
| 2802 | * allocation will fail, but use the maximum possible |
| 2803 | * value and carry on with prof_alloc_prep(), just in |
| 2804 | * case allocation succeeds. |
| 2805 | */ |
| 2806 | usize_max = LARGE_MAXCLASS; |
| 2807 | } |
| 2808 | } |
| 2809 | tctx = prof_alloc_prep(tsd, usize_max, prof_active, false); |
| 2810 | |
| 2811 | if (unlikely((uintptr_t)tctx != (uintptr_t)1U)) { |
| 2812 | usize = ixallocx_prof_sample(tsd_tsdn(tsd), ptr, old_usize, |
| 2813 | size, extra, alignment, zero, tctx); |
| 2814 | } else { |
| 2815 | usize = ixallocx_helper(tsd_tsdn(tsd), ptr, old_usize, size, |
| 2816 | extra, alignment, zero); |
| 2817 | } |
| 2818 | if (usize == old_usize) { |
| 2819 | prof_alloc_rollback(tsd, tctx, false); |
| 2820 | return usize; |
| 2821 | } |
| 2822 | prof_realloc(tsd, ptr, usize, tctx, prof_active, false, ptr, old_usize, |
| 2823 | old_tctx); |
| 2824 | |
| 2825 | return usize; |
| 2826 | } |
| 2827 | |
| 2828 | JEMALLOC_EXPORT size_t JEMALLOC_NOTHROW |
| 2829 | je_xallocx(void *ptr, size_t size, size_t extra, int flags) { |
no test coverage detected