| 1457 | arena_dalloc_junk_small_impl; |
| 1458 | |
| 1459 | static void * |
| 1460 | arena_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 | |
| 1513 | void * |
| 1514 | arena_malloc_hard(tsdn_t *tsdn, arena_t *arena, size_t size, szind_t ind, |
no test coverage detected