MCPcopy Create free account
hub / github.com/catboost/catboost / LFGetSize

Function LFGetSize

library/cpp/lfalloc/lf_allocX64.h:1652–1670  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1650}
1651
1652static size_t LFGetSize(const void* p) {
1653#if defined(LFALLOC_DBG)
1654 if (p == nullptr)
1655 return 0;
1656 return GetOrigAllocHeader(const_cast<void*>(p))->Size;
1657#endif
1658
1659 uintptr_t chkOffset = ((const char*)p - ALLOC_START);
1660 if (chkOffset >= N_MAX_WORKSET_SIZE) {
1661 if (p == nullptr)
1662 return 0;
1663 return TLargeBlk::As(p)->Pages * 4096ll;
1664 }
1665 uintptr_t chunk = ((const char*)p - ALLOC_START) / N_CHUNK_SIZE;
1666 ptrdiff_t nSizeIdx = chunkSizeIdx[chunk];
1667 if (nSizeIdx <= 0)
1668 return TLargeBlk::As(p)->Pages * 4096ll;
1669 return nSizeIdxToSize[nSizeIdx];
1670}
1671
1672////////////////////////////////////////////////////////////////////////////////////////////////////
1673// Output mem alloc stats

Callers 2

reallocFunction · 0.85
malloc_usable_sizeFunction · 0.85

Calls 1

GetOrigAllocHeaderFunction · 0.85

Tested by

no test coverage detected