mirror of
https://github.com/jemalloc/jemalloc.git
synced 2026-08-24 16:13:38 +03:00
Refactor chunk_dalloc_{cache,wrapper}() to take extent arguments.
Rename arena_extent_[d]alloc() to extent_[d]alloc(). Move all chunk [de]registration responsibility into chunk.c.
This commit is contained in:
parent
de0305a7f3
commit
6c94470822
10 changed files with 148 additions and 199 deletions
26
src/extent.c
26
src/extent.c
|
|
@ -3,6 +3,32 @@
|
|||
|
||||
/******************************************************************************/
|
||||
|
||||
extent_t *
|
||||
extent_alloc(tsdn_t *tsdn, arena_t *arena)
|
||||
{
|
||||
extent_t *extent;
|
||||
|
||||
malloc_mutex_lock(tsdn, &arena->extent_cache_mtx);
|
||||
extent = ql_last(&arena->extent_cache, ql_link);
|
||||
if (extent == NULL) {
|
||||
malloc_mutex_unlock(tsdn, &arena->extent_cache_mtx);
|
||||
return (base_alloc(tsdn, sizeof(extent_t)));
|
||||
}
|
||||
ql_tail_remove(&arena->extent_cache, extent_t, ql_link);
|
||||
malloc_mutex_unlock(tsdn, &arena->extent_cache_mtx);
|
||||
return (extent);
|
||||
}
|
||||
|
||||
void
|
||||
extent_dalloc(tsdn_t *tsdn, arena_t *arena, extent_t *extent)
|
||||
{
|
||||
|
||||
malloc_mutex_lock(tsdn, &arena->extent_cache_mtx);
|
||||
ql_elm_new(extent, ql_link);
|
||||
ql_tail_insert(&arena->extent_cache, extent, ql_link);
|
||||
malloc_mutex_unlock(tsdn, &arena->extent_cache_mtx);
|
||||
}
|
||||
|
||||
#ifdef JEMALLOC_JET
|
||||
#undef extent_size_quantize_floor
|
||||
#define extent_size_quantize_floor JEMALLOC_N(n_extent_size_quantize_floor)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue