MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / arena_malloc_small

Function arena_malloc_small

deps/jemalloc/src/arena.c:1459–1511  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1457 arena_dalloc_junk_small_impl;
1458
1459static void *
1460arena_malloc_small(tsdn_t *tsdn, arena_t *arena, szind_t binind, bool zero) {
1461 void *ret;
1462 bin_t *bin;
1463 size_t usize;
1464 extent_t *slab;
1465
1466 assert(binind < SC_NBINS);
1467 usize = sz_index2size(binind);
1468 unsigned binshard;
1469 bin = arena_bin_choose_lock(tsdn, arena, binind, &binshard);
1470
1471 if ((slab = bin->slabcur) != NULL && extent_nfree_get(slab) > 0) {
1472 ret = arena_slab_reg_alloc(slab, &bin_infos[binind]);
1473 } else {
1474 ret = arena_bin_malloc_hard(tsdn, arena, bin, binind, binshard);
1475 }
1476
1477 if (ret == NULL) {
1478 malloc_mutex_unlock(tsdn, &bin->lock);
1479 return NULL;
1480 }
1481
1482 if (config_stats) {
1483 bin->stats.nmalloc++;
1484 bin->stats.nrequests++;
1485 bin->stats.curregs++;
1486 }
1487 malloc_mutex_unlock(tsdn, &bin->lock);
1488 if (config_prof && arena_prof_accum(tsdn, arena, usize)) {
1489 prof_idump(tsdn);
1490 }
1491
1492 if (!zero) {
1493 if (config_fill) {
1494 if (unlikely(opt_junk_alloc)) {
1495 arena_alloc_junk_small(ret,
1496 &bin_infos[binind], false);
1497 } else if (unlikely(opt_zero)) {
1498 memset(ret, 0, usize);
1499 }
1500 }
1501 } else {
1502 if (config_fill && unlikely(opt_junk_alloc)) {
1503 arena_alloc_junk_small(ret, &bin_infos[binind],
1504 true);
1505 }
1506 memset(ret, 0, usize);
1507 }
1508
1509 arena_decay_tick(tsdn, arena);
1510 return ret;
1511}
1512
1513void *
1514arena_malloc_hard(tsdn_t *tsdn, arena_t *arena, size_t size, szind_t ind,

Callers 1

arena_malloc_hardFunction · 0.70

Calls 10

arena_bin_choose_lockFunction · 0.85
arena_slab_reg_allocFunction · 0.70
arena_bin_malloc_hardFunction · 0.70
prof_idumpFunction · 0.70
arena_alloc_junk_smallFunction · 0.70
sz_index2sizeFunction · 0.50
extent_nfree_getFunction · 0.50
malloc_mutex_unlockFunction · 0.50
arena_prof_accumFunction · 0.50
arena_decay_tickFunction · 0.50

Tested by

no test coverage detected