| 1314 | arena_dalloc_junk_small_impl; |
| 1315 | |
| 1316 | static void * |
| 1317 | arena_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 | |
| 1370 | void * |
| 1371 | arena_malloc_hard(tsdn_t *tsdn, arena_t *arena, size_t size, szind_t ind, |
no test coverage detected