MCPcopy Create free account
hub / github.com/OpenStarbound/OpenStarbound / _rpmalloc_span_release_to_cache

Function _rpmalloc_span_release_to_cache

source/extern/rpmalloc.c:1290–1308  ·  view source on GitHub ↗

Move the span (used for small or medium allocations) to the heap thread cache

Source from the content-addressed store, hash-verified

1288
1289//! Move the span (used for small or medium allocations) to the heap thread cache
1290static void
1291_rpmalloc_span_release_to_cache(heap_t* heap, span_t* span) {
1292 rpmalloc_assert(heap == span->heap, "Span heap pointer corrupted");
1293 rpmalloc_assert(span->size_class < SIZE_CLASS_COUNT, "Invalid span size class");
1294 rpmalloc_assert(span->span_count == 1, "Invalid span count");
1295#if ENABLE_ADAPTIVE_THREAD_CACHE || ENABLE_STATISTICS
1296 atomic_decr32(&heap->span_use[0].current);
1297#endif
1298 _rpmalloc_stat_dec(&heap->size_class_use[span->size_class].spans_current);
1299 if (!heap->finalize) {
1300 _rpmalloc_stat_inc(&heap->span_use[0].spans_to_cache);
1301 _rpmalloc_stat_inc(&heap->size_class_use[span->size_class].spans_to_cache);
1302 if (heap->size_class[span->size_class].cache)
1303 _rpmalloc_heap_cache_insert(heap, heap->size_class[span->size_class].cache);
1304 heap->size_class[span->size_class].cache = span;
1305 } else {
1306 _rpmalloc_span_unmap(span);
1307 }
1308}
1309
1310//! Initialize a (partial) free list up to next system memory page, while reserving the first block
1311//! as allocated, returning number of blocks in list

Calls 3

atomic_decr32Function · 0.85
_rpmalloc_span_unmapFunction · 0.85

Tested by

no test coverage detected