| 1398 | |
| 1399 | static const int DBG_ALLOC_INVALID_COOKIE = -1; |
| 1400 | static inline int SampleAllocation(TAllocHeader* p, int sizeIdx) { |
| 1401 | int cookie = DBG_ALLOC_INVALID_COOKIE; |
| 1402 | if (AllocationSamplingEnabled && (ProfileCurrentThread || ProfileAllThreads) && !InAllocationCallback) { |
| 1403 | if (p->Size > AllocationSampleMaxSize || ++AllocationsCount % AllocationSampleRate == 0) { |
| 1404 | if (AllocationCallback) { |
| 1405 | InAllocationCallback = true; |
| 1406 | cookie = AllocationCallback(p->Tag, p->Size, sizeIdx); |
| 1407 | InAllocationCallback = false; |
| 1408 | } |
| 1409 | } |
| 1410 | } |
| 1411 | return cookie; |
| 1412 | } |
| 1413 | |
| 1414 | static inline void SampleDeallocation(TAllocHeader* p, int sizeIdx) { |
| 1415 | if (p->Cookie != DBG_ALLOC_INVALID_COOKIE && !InAllocationCallback) { |