MCPcopy Create free account
hub / github.com/F-Stack/f-stack / imalloc_body

Function imalloc_body

app/redis-6.2.6/deps/jemalloc/src/jemalloc.c:1786–1981  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1784}
1785
1786JEMALLOC_ALWAYS_INLINE int
1787imalloc_body(static_opts_t *sopts, dynamic_opts_t *dopts, tsd_t *tsd) {
1788 /* Where the actual allocated memory will live. */
1789 void *allocation = NULL;
1790 /* Filled in by compute_size_with_overflow below. */
1791 size_t size = 0;
1792 /*
1793 * For unaligned allocations, we need only ind. For aligned
1794 * allocations, or in case of stats or profiling we need usize.
1795 *
1796 * These are actually dead stores, in that their values are reset before
1797 * any branch on their value is taken. Sometimes though, it's
1798 * convenient to pass them as arguments before this point. To avoid
1799 * undefined behavior then, we initialize them with dummy stores.
1800 */
1801 szind_t ind = 0;
1802 size_t usize = 0;
1803
1804 /* Reentrancy is only checked on slow path. */
1805 int8_t reentrancy_level;
1806
1807 /* Compute the amount of memory the user wants. */
1808 if (unlikely(compute_size_with_overflow(sopts->may_overflow, dopts,
1809 &size))) {
1810 goto label_oom;
1811 }
1812
1813 /* Validate the user input. */
1814 if (sopts->bump_empty_alloc) {
1815 if (unlikely(size == 0)) {
1816 size = 1;
1817 }
1818 }
1819
1820 if (sopts->assert_nonempty_alloc) {
1821 assert (size != 0);
1822 }
1823
1824 if (unlikely(dopts->alignment < sopts->min_alignment
1825 || (dopts->alignment & (dopts->alignment - 1)) != 0)) {
1826 goto label_invalid_alignment;
1827 }
1828
1829 /* This is the beginning of the "core" algorithm. */
1830
1831 if (dopts->alignment == 0) {
1832 ind = sz_size2index(size);
1833 if (unlikely(ind >= NSIZES)) {
1834 goto label_oom;
1835 }
1836 if (config_stats || (config_prof && opt_prof)) {
1837 usize = sz_index2size(ind);
1838 assert(usize > 0 && usize <= LARGE_MAXCLASS);
1839 }
1840 } else {
1841 usize = sz_sa2u(size, dopts->alignment);
1842 if (unlikely(usize == 0 || usize > LARGE_MAXCLASS)) {
1843 goto label_oom;

Callers 1

imallocFunction · 0.85

Calls 14

sz_size2indexFunction · 0.85
sz_index2sizeFunction · 0.85
sz_sa2uFunction · 0.85
check_entry_exit_lockingFunction · 0.85
tsd_tsdnFunction · 0.85
prof_active_get_unlockedFunction · 0.85
imalloc_no_sampleFunction · 0.85
imalloc_sampleFunction · 0.85
prof_mallocFunction · 0.85
isallocFunction · 0.85
malloc_writeFunction · 0.85

Tested by

no test coverage detected