| 1472 | }; |
| 1473 | |
| 1474 | extern "C" void GetPerTagAllocInfo( |
| 1475 | bool flushPerThreadCounters, |
| 1476 | TPerTagAllocInfo* info, |
| 1477 | int& maxTag, |
| 1478 | int& numSizes) { |
| 1479 | maxTag = DBG_ALLOC_MAX_TAG; |
| 1480 | numSizes = DBG_ALLOC_NUM_SIZES; |
| 1481 | |
| 1482 | if (info) { |
| 1483 | if (flushPerThreadCounters) { |
| 1484 | TLFLockHolder ll(&LFLockThreadInfo); |
| 1485 | for (TThreadAllocInfo** p = &pThreadInfoList; *p;) { |
| 1486 | TThreadAllocInfo* pInfo = *p; |
| 1487 | for (int tag = 0; tag < DBG_ALLOC_MAX_TAG; ++tag) { |
| 1488 | for (int sizeIdx = 0; sizeIdx < DBG_ALLOC_NUM_SIZES; ++sizeIdx) { |
| 1489 | auto& local = pInfo->LocalPerTagAllocCounters[tag][sizeIdx]; |
| 1490 | auto& global = GlobalPerTagAllocCounters[tag][sizeIdx]; |
| 1491 | local.Flush(global); |
| 1492 | } |
| 1493 | } |
| 1494 | p = &pInfo->pNextInfo; |
| 1495 | } |
| 1496 | } |
| 1497 | |
| 1498 | for (int tag = 0; tag < DBG_ALLOC_MAX_TAG; ++tag) { |
| 1499 | for (int sizeIdx = 0; sizeIdx < DBG_ALLOC_NUM_SIZES; ++sizeIdx) { |
| 1500 | auto& global = GlobalPerTagAllocCounters[tag][sizeIdx]; |
| 1501 | auto& res = info[tag * DBG_ALLOC_NUM_SIZES + sizeIdx]; |
| 1502 | res.Count = global.Count; |
| 1503 | res.Size = global.Size; |
| 1504 | } |
| 1505 | } |
| 1506 | } |
| 1507 | } |
| 1508 | |
| 1509 | #endif // LFALLOC_DBG |
| 1510 | |