| 2493 | } |
| 2494 | |
| 2495 | JEMALLOC_ALWAYS_INLINE void * |
| 2496 | irallocx_prof(tsd_t *tsd, void *old_ptr, size_t old_usize, size_t size, |
| 2497 | size_t alignment, size_t *usize, bool zero, tcache_t *tcache, |
| 2498 | arena_t *arena, alloc_ctx_t *alloc_ctx) { |
| 2499 | void *p; |
| 2500 | bool prof_active; |
| 2501 | prof_tctx_t *old_tctx, *tctx; |
| 2502 | |
| 2503 | prof_active = prof_active_get_unlocked(); |
| 2504 | old_tctx = prof_tctx_get(tsd_tsdn(tsd), old_ptr, alloc_ctx); |
| 2505 | tctx = prof_alloc_prep(tsd, *usize, prof_active, false); |
| 2506 | if (unlikely((uintptr_t)tctx != (uintptr_t)1U)) { |
| 2507 | p = irallocx_prof_sample(tsd_tsdn(tsd), old_ptr, old_usize, |
| 2508 | *usize, alignment, zero, tcache, arena, tctx); |
| 2509 | } else { |
| 2510 | p = iralloct(tsd_tsdn(tsd), old_ptr, old_usize, size, alignment, |
| 2511 | zero, tcache, arena); |
| 2512 | } |
| 2513 | if (unlikely(p == NULL)) { |
| 2514 | prof_alloc_rollback(tsd, tctx, false); |
| 2515 | return NULL; |
| 2516 | } |
| 2517 | |
| 2518 | if (p == old_ptr && alignment != 0) { |
| 2519 | /* |
| 2520 | * The allocation did not move, so it is possible that the size |
| 2521 | * class is smaller than would guarantee the requested |
| 2522 | * alignment, and that the alignment constraint was |
| 2523 | * serendipitously satisfied. Additionally, old_usize may not |
| 2524 | * be the same as the current usize because of in-place large |
| 2525 | * reallocation. Therefore, query the actual value of usize. |
| 2526 | */ |
| 2527 | *usize = isalloc(tsd_tsdn(tsd), p); |
| 2528 | } |
| 2529 | prof_realloc(tsd, p, *usize, tctx, prof_active, false, old_ptr, |
| 2530 | old_usize, old_tctx); |
| 2531 | |
| 2532 | return p; |
| 2533 | } |
| 2534 | |
| 2535 | JEMALLOC_EXPORT JEMALLOC_ALLOCATOR JEMALLOC_RESTRICT_RETURN |
| 2536 | void JEMALLOC_NOTHROW * |
no test coverage detected