| 599 | } |
| 600 | |
| 601 | inline void* do_malloc(size_t size) { |
| 602 | void* ret = NULL; |
| 603 | |
| 604 | // The following call forces module initialization |
| 605 | ThreadCache* heap = ThreadCache::GetCache(); |
| 606 | if (size <= kMaxSize) { |
| 607 | // The common case, and also the simplest. This just pops the |
| 608 | // size-appropriate freelist, after replenishing it if it's empty. |
| 609 | ret = CheckedMallocResult(heap->Allocate(size)); |
| 610 | } else { |
| 611 | ret = do_malloc_pages(tcmalloc::pages(size)); |
| 612 | } |
| 613 | if (ret == NULL) errno = ENOMEM; |
| 614 | return ret; |
| 615 | } |
| 616 | |
| 617 | inline void* do_calloc(size_t n, size_t elem_size) { |
| 618 | // Overflow check |
no test coverage detected