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

Function arena_i_extent_hooks_ctl

deps/jemalloc/src/ctl.c:2370–2423  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2368}
2369
2370static int
2371arena_i_extent_hooks_ctl(tsd_t *tsd, const size_t *mib, size_t miblen,
2372 void *oldp, size_t *oldlenp, void *newp, size_t newlen) {
2373 int ret;
2374 unsigned arena_ind;
2375 arena_t *arena;
2376
2377 malloc_mutex_lock(tsd_tsdn(tsd), &ctl_mtx);
2378 MIB_UNSIGNED(arena_ind, 1);
2379 if (arena_ind < narenas_total_get()) {
2380 extent_hooks_t *old_extent_hooks;
2381 arena = arena_get(tsd_tsdn(tsd), arena_ind, false);
2382 if (arena == NULL) {
2383 if (arena_ind >= narenas_auto) {
2384 ret = EFAULT;
2385 goto label_return;
2386 }
2387 old_extent_hooks =
2388 (extent_hooks_t *)&extent_hooks_default;
2389 READ(old_extent_hooks, extent_hooks_t *);
2390 if (newp != NULL) {
2391 /* Initialize a new arena as a side effect. */
2392 extent_hooks_t *new_extent_hooks
2393 JEMALLOC_CC_SILENCE_INIT(NULL);
2394 WRITE(new_extent_hooks, extent_hooks_t *);
2395 arena = arena_init(tsd_tsdn(tsd), arena_ind,
2396 new_extent_hooks);
2397 if (arena == NULL) {
2398 ret = EFAULT;
2399 goto label_return;
2400 }
2401 }
2402 } else {
2403 if (newp != NULL) {
2404 extent_hooks_t *new_extent_hooks
2405 JEMALLOC_CC_SILENCE_INIT(NULL);
2406 WRITE(new_extent_hooks, extent_hooks_t *);
2407 old_extent_hooks = extent_hooks_set(tsd, arena,
2408 new_extent_hooks);
2409 READ(old_extent_hooks, extent_hooks_t *);
2410 } else {
2411 old_extent_hooks = extent_hooks_get(arena);
2412 READ(old_extent_hooks, extent_hooks_t *);
2413 }
2414 }
2415 } else {
2416 ret = EFAULT;
2417 goto label_return;
2418 }
2419 ret = 0;
2420label_return:
2421 malloc_mutex_unlock(tsd_tsdn(tsd), &ctl_mtx);
2422 return ret;
2423}
2424
2425static int
2426arena_i_retain_grow_limit_ctl(tsd_t *tsd, const size_t *mib,

Callers

nothing calls this directly

Calls 8

narenas_total_getFunction · 0.70
arena_initFunction · 0.70
extent_hooks_setFunction · 0.70
extent_hooks_getFunction · 0.70
malloc_mutex_lockFunction · 0.50
tsd_tsdnFunction · 0.50
arena_getFunction · 0.50
malloc_mutex_unlockFunction · 0.50

Tested by

no test coverage detected