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

Function base_extent_alloc

deps/memkind/src/jemalloc/src/base.c:200–226  ·  view source on GitHub ↗

* Allocate an extent that is at least as large as specified size, with * specified alignment. */

Source from the content-addressed store, hash-verified

198 * specified alignment.
199 */
200static extent_t *
201base_extent_alloc(tsdn_t *tsdn, base_t *base, size_t size, size_t alignment) {
202 malloc_mutex_assert_owner(tsdn, &base->mtx);
203
204 extent_hooks_t *extent_hooks = base_extent_hooks_get(base);
205 /*
206 * Drop mutex during base_block_alloc(), because an extent hook will be
207 * called.
208 */
209 malloc_mutex_unlock(tsdn, &base->mtx);
210 base_block_t *block = base_block_alloc(extent_hooks, base_ind_get(base),
211 &base->pind_last, &base->extent_sn_next, size, alignment);
212 malloc_mutex_lock(tsdn, &base->mtx);
213 if (block == NULL) {
214 return NULL;
215 }
216 block->next = base->blocks;
217 base->blocks = block;
218 if (config_stats) {
219 base->allocated += sizeof(base_block_t);
220 base->resident += PAGE_CEILING(sizeof(base_block_t));
221 base->mapped += block->size;
222 assert(base->allocated <= base->resident);
223 assert(base->resident <= base->mapped);
224 }
225 return &block->extent;
226}
227
228base_t *
229b0get(void) {

Callers 1

base_alloc_implFunction · 0.70

Calls 6

base_extent_hooks_getFunction · 0.70
base_block_allocFunction · 0.70
malloc_mutex_unlockFunction · 0.50
base_ind_getFunction · 0.50
malloc_mutex_lockFunction · 0.50

Tested by

no test coverage detected