| 508 | #endif |
| 509 | |
| 510 | static void LargeBlockFree(void* p, ELFAllocCounter counter) { |
| 511 | if (p == nullptr) |
| 512 | return; |
| 513 | #ifdef _MSC_VER |
| 514 | VirtualFree((char*)p - 4096ll, 0, MEM_RELEASE); |
| 515 | #else |
| 516 | size_t pgCount = TLargeBlk::As(p)->Pages; |
| 517 | |
| 518 | TLargeBlk::As(p)->Mark(ELarge::Free); |
| 519 | IncrementCounter(counter, pgCount * 4096ll); |
| 520 | IncrementCounter(CT_SYSTEM_FREE, 4096ll); |
| 521 | |
| 522 | if (lbFreePageCount > LB_LIMIT_TOTAL_SIZE) |
| 523 | FreeAllLargeBlockMem(); |
| 524 | int lbHash = pgCount % LB_BUF_HASH; |
| 525 | for (int i = 0; i < LB_BUF_SIZE; ++i) { |
| 526 | if (lbFreePtrs[lbHash][i] == nullptr) { |
| 527 | if (DoCas(&lbFreePtrs[lbHash][i], p, (void*)nullptr) == nullptr) { |
| 528 | AtomicAdd(lbFreePageCount, pgCount); |
| 529 | return; |
| 530 | } |
| 531 | } |
| 532 | } |
| 533 | |
| 534 | LargeBlockUnmap(p, pgCount); |
| 535 | #endif |
| 536 | } |
| 537 | |
| 538 | static void* SystemAlloc(size_t _nSize) { |
| 539 | //HeapAlloc(GetProcessHeap(), HEAP_GENERATE_EXCEPTIONS, _nSize); |
no test coverage detected