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

Function arena_malloc_small

app/redis-6.2.6/deps/jemalloc/src/arena.c:1316–1368  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1314 arena_dalloc_junk_small_impl;
1315
1316static void *
1317arena_malloc_small(tsdn_t *tsdn, arena_t *arena, szind_t binind, bool zero) {
1318 void *ret;
1319 bin_t *bin;
1320 size_t usize;
1321 extent_t *slab;
1322
1323 assert(binind < NBINS);
1324 bin = &arena->bins[binind];
1325 usize = sz_index2size(binind);
1326
1327 malloc_mutex_lock(tsdn, &bin->lock);
1328 if ((slab = bin->slabcur) != NULL && extent_nfree_get(slab) > 0) {
1329 ret = arena_slab_reg_alloc(slab, &bin_infos[binind]);
1330 } else {
1331 ret = arena_bin_malloc_hard(tsdn, arena, bin, binind);
1332 }
1333
1334 if (ret == NULL) {
1335 malloc_mutex_unlock(tsdn, &bin->lock);
1336 return NULL;
1337 }
1338
1339 if (config_stats) {
1340 bin->stats.nmalloc++;
1341 bin->stats.nrequests++;
1342 bin->stats.curregs++;
1343 }
1344 malloc_mutex_unlock(tsdn, &bin->lock);
1345 if (config_prof && arena_prof_accum(tsdn, arena, usize)) {
1346 prof_idump(tsdn);
1347 }
1348
1349 if (!zero) {
1350 if (config_fill) {
1351 if (unlikely(opt_junk_alloc)) {
1352 arena_alloc_junk_small(ret,
1353 &bin_infos[binind], false);
1354 } else if (unlikely(opt_zero)) {
1355 memset(ret, 0, usize);
1356 }
1357 }
1358 } else {
1359 if (config_fill && unlikely(opt_junk_alloc)) {
1360 arena_alloc_junk_small(ret, &bin_infos[binind],
1361 true);
1362 }
1363 memset(ret, 0, usize);
1364 }
1365
1366 arena_decay_tick(tsdn, arena);
1367 return ret;
1368}
1369
1370void *
1371arena_malloc_hard(tsdn_t *tsdn, arena_t *arena, size_t size, szind_t ind,

Callers 1

arena_malloc_hardFunction · 0.85

Calls 11

sz_index2sizeFunction · 0.85
malloc_mutex_lockFunction · 0.85
extent_nfree_getFunction · 0.85
arena_slab_reg_allocFunction · 0.85
arena_bin_malloc_hardFunction · 0.85
malloc_mutex_unlockFunction · 0.85
arena_prof_accumFunction · 0.85
prof_idumpFunction · 0.85
arena_alloc_junk_smallFunction · 0.85
memsetFunction · 0.85
arena_decay_tickFunction · 0.85

Tested by

no test coverage detected