| 1711 | } |
| 1712 | |
| 1713 | JEMALLOC_ALWAYS_INLINE void * |
| 1714 | imalloc_sample(static_opts_t *sopts, dynamic_opts_t *dopts, tsd_t *tsd, |
| 1715 | size_t usize, szind_t ind) { |
| 1716 | void *ret; |
| 1717 | |
| 1718 | /* |
| 1719 | * For small allocations, sampling bumps the usize. If so, we allocate |
| 1720 | * from the ind_large bucket. |
| 1721 | */ |
| 1722 | szind_t ind_large; |
| 1723 | size_t bumped_usize = usize; |
| 1724 | |
| 1725 | if (usize <= SMALL_MAXCLASS) { |
| 1726 | assert(((dopts->alignment == 0) ? sz_s2u(LARGE_MINCLASS) : |
| 1727 | sz_sa2u(LARGE_MINCLASS, dopts->alignment)) |
| 1728 | == LARGE_MINCLASS); |
| 1729 | ind_large = sz_size2index(LARGE_MINCLASS); |
| 1730 | bumped_usize = sz_s2u(LARGE_MINCLASS); |
| 1731 | ret = imalloc_no_sample(sopts, dopts, tsd, bumped_usize, |
| 1732 | bumped_usize, ind_large); |
| 1733 | if (unlikely(ret == NULL)) { |
| 1734 | return NULL; |
| 1735 | } |
| 1736 | arena_prof_promote(tsd_tsdn(tsd), ret, usize); |
| 1737 | } else { |
| 1738 | ret = imalloc_no_sample(sopts, dopts, tsd, usize, usize, ind); |
| 1739 | } |
| 1740 | |
| 1741 | return ret; |
| 1742 | } |
| 1743 | |
| 1744 | /* |
| 1745 | * Returns true if the allocation will overflow, and false otherwise. Sets |
no test coverage detected