MCPcopy Create free account
hub / github.com/beefytech/Beef / do_malloc_pages

Function do_malloc_pages

BeefRT/gperftools/src/tcmalloc.cc:1074–1098  ·  view source on GitHub ↗

Helper for do_malloc().

Source from the content-addressed store, hash-verified

1072
1073// Helper for do_malloc().
1074inline void* do_malloc_pages(ThreadCache* heap, size_t size) {
1075 void* result;
1076 bool report_large;
1077
1078 heap->requested_bytes_ += size;
1079 Length num_pages = TCMALLOC_NAMESPACE::pages(size);
1080 size = num_pages << kPageShift;
1081
1082 if ((TCMALLOC_NAMESPACE::FLAGS_tcmalloc_sample_parameter > 0) && heap->SampleAllocation(size)) {
1083 result = DoSampledAllocation(size);
1084
1085 SpinLockHolder h(Static::pageheap_lock());
1086 report_large = should_report_large(num_pages);
1087 } else {
1088 SpinLockHolder h(Static::pageheap_lock());
1089 Span* span = Static::pageheap()->New(num_pages);
1090 result = (UNLIKELY(span == NULL) ? NULL : SpanToMallocResult(span));
1091 report_large = should_report_large(num_pages);
1092 }
1093
1094 if (report_large) {
1095 ReportLargeAlloc(num_pages, result);
1096 }
1097 return result;
1098}
1099
1100inline void* do_malloc_small(ThreadCache* heap, size_t size) {
1101 ASSERT(Static::IsInited());

Callers 1

do_malloc_no_errnoFunction · 0.70

Calls 7

pagesFunction · 0.70
DoSampledAllocationFunction · 0.70
should_report_largeFunction · 0.70
SpanToMallocResultFunction · 0.70
ReportLargeAllocFunction · 0.70
SampleAllocationMethod · 0.45
NewMethod · 0.45

Tested by

no test coverage detected