Helper for do_malloc().
| 1072 | |
| 1073 | // Helper for do_malloc(). |
| 1074 | inline 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 | |
| 1100 | inline void* do_malloc_small(ThreadCache* heap, size_t size) { |
| 1101 | ASSERT(Static::IsInited()); |
no test coverage detected