| 29 | } |
| 30 | |
| 31 | size_t TMemoryPool::DoClear(bool keepfirst) noexcept { |
| 32 | size_t chunksUsed = 0; |
| 33 | while (!Chunks_.Empty()) { |
| 34 | chunksUsed += 1; |
| 35 | TChunk* c = Chunks_.PopBack(); |
| 36 | |
| 37 | if (keepfirst && Chunks_.Empty()) { |
| 38 | c->ResetChunk(); |
| 39 | Chunks_.PushBack(c); |
| 40 | Current_ = c; |
| 41 | BlockSize_ = c->BlockLength() - sizeof(TChunk); |
| 42 | MemoryAllocatedBeforeCurrent_ = 0; |
| 43 | MemoryWasteBeforeCurrent_ = 0; |
| 44 | return chunksUsed; |
| 45 | } |
| 46 | |
| 47 | TBlock b = {c, c->BlockLength()}; |
| 48 | |
| 49 | c->~TChunk(); |
| 50 | Alloc_->Release(b); |
| 51 | } |
| 52 | |
| 53 | Current_ = &Empty_; |
| 54 | BlockSize_ = Origin_; |
| 55 | MemoryAllocatedBeforeCurrent_ = 0; |
| 56 | MemoryWasteBeforeCurrent_ = 0; |
| 57 | return chunksUsed; |
| 58 | } |
nothing calls this directly
no test coverage detected