| 3171 | } |
| 3172 | |
| 3173 | JEMALLOC_ALWAYS_INLINE void * |
| 3174 | irallocx_prof(tsd_t *tsd, void *old_ptr, size_t old_usize, size_t size, |
| 3175 | size_t alignment, size_t *usize, bool zero, tcache_t *tcache, |
| 3176 | arena_t *arena, alloc_ctx_t *alloc_ctx, hook_ralloc_args_t *hook_args) { |
| 3177 | void *p; |
| 3178 | bool prof_active; |
| 3179 | prof_tctx_t *old_tctx, *tctx; |
| 3180 | |
| 3181 | prof_active = prof_active_get_unlocked(); |
| 3182 | old_tctx = prof_tctx_get(tsd_tsdn(tsd), old_ptr, alloc_ctx); |
| 3183 | tctx = prof_alloc_prep(tsd, *usize, prof_active, false); |
| 3184 | if (unlikely((uintptr_t)tctx != (uintptr_t)1U)) { |
| 3185 | p = irallocx_prof_sample(tsd_tsdn(tsd), old_ptr, old_usize, |
| 3186 | *usize, alignment, zero, tcache, arena, tctx, hook_args); |
| 3187 | } else { |
| 3188 | p = iralloct(tsd_tsdn(tsd), old_ptr, old_usize, size, alignment, |
| 3189 | zero, tcache, arena, hook_args); |
| 3190 | } |
| 3191 | if (unlikely(p == NULL)) { |
| 3192 | prof_alloc_rollback(tsd, tctx, false); |
| 3193 | return NULL; |
| 3194 | } |
| 3195 | |
| 3196 | if (p == old_ptr && alignment != 0) { |
| 3197 | /* |
| 3198 | * The allocation did not move, so it is possible that the size |
| 3199 | * class is smaller than would guarantee the requested |
| 3200 | * alignment, and that the alignment constraint was |
| 3201 | * serendipitously satisfied. Additionally, old_usize may not |
| 3202 | * be the same as the current usize because of in-place large |
| 3203 | * reallocation. Therefore, query the actual value of usize. |
| 3204 | */ |
| 3205 | *usize = isalloc(tsd_tsdn(tsd), p); |
| 3206 | } |
| 3207 | prof_realloc(tsd, p, *usize, tctx, prof_active, false, old_ptr, |
| 3208 | old_usize, old_tctx); |
| 3209 | |
| 3210 | return p; |
| 3211 | } |
| 3212 | |
| 3213 | JEMALLOC_EXPORT JEMALLOC_ALLOCATOR JEMALLOC_RESTRICT_RETURN |
| 3214 | void JEMALLOC_NOTHROW * |
no test coverage detected