| 3336 | } |
| 3337 | |
| 3338 | JEMALLOC_ALWAYS_INLINE size_t |
| 3339 | ixallocx_prof(tsd_t *tsd, void *ptr, size_t old_usize, size_t size, |
| 3340 | size_t extra, size_t alignment, bool zero, alloc_ctx_t *alloc_ctx) { |
| 3341 | size_t usize_max, usize; |
| 3342 | bool prof_active; |
| 3343 | prof_tctx_t *old_tctx, *tctx; |
| 3344 | |
| 3345 | prof_active = prof_active_get_unlocked(); |
| 3346 | old_tctx = prof_tctx_get(tsd_tsdn(tsd), ptr, alloc_ctx); |
| 3347 | /* |
| 3348 | * usize isn't knowable before ixalloc() returns when extra is non-zero. |
| 3349 | * Therefore, compute its maximum possible value and use that in |
| 3350 | * prof_alloc_prep() to decide whether to capture a backtrace. |
| 3351 | * prof_realloc() will use the actual usize to decide whether to sample. |
| 3352 | */ |
| 3353 | if (alignment == 0) { |
| 3354 | usize_max = sz_s2u(size+extra); |
| 3355 | assert(usize_max > 0 |
| 3356 | && usize_max <= SC_LARGE_MAXCLASS); |
| 3357 | } else { |
| 3358 | usize_max = sz_sa2u(size+extra, alignment); |
| 3359 | if (unlikely(usize_max == 0 |
| 3360 | || usize_max > SC_LARGE_MAXCLASS)) { |
| 3361 | /* |
| 3362 | * usize_max is out of range, and chances are that |
| 3363 | * allocation will fail, but use the maximum possible |
| 3364 | * value and carry on with prof_alloc_prep(), just in |
| 3365 | * case allocation succeeds. |
| 3366 | */ |
| 3367 | usize_max = SC_LARGE_MAXCLASS; |
| 3368 | } |
| 3369 | } |
| 3370 | tctx = prof_alloc_prep(tsd, usize_max, prof_active, false); |
| 3371 | |
| 3372 | if (unlikely((uintptr_t)tctx != (uintptr_t)1U)) { |
| 3373 | usize = ixallocx_prof_sample(tsd_tsdn(tsd), ptr, old_usize, |
| 3374 | size, extra, alignment, zero, tctx); |
| 3375 | } else { |
| 3376 | usize = ixallocx_helper(tsd_tsdn(tsd), ptr, old_usize, size, |
| 3377 | extra, alignment, zero); |
| 3378 | } |
| 3379 | if (usize == old_usize) { |
| 3380 | prof_alloc_rollback(tsd, tctx, false); |
| 3381 | return usize; |
| 3382 | } |
| 3383 | prof_realloc(tsd, ptr, usize, tctx, prof_active, false, ptr, old_usize, |
| 3384 | old_tctx); |
| 3385 | |
| 3386 | return usize; |
| 3387 | } |
| 3388 | |
| 3389 | JEMALLOC_EXPORT size_t JEMALLOC_NOTHROW |
| 3390 | je_xallocx(void *ptr, size_t size, size_t extra, int flags) { |
no test coverage detected