| 133 | } |
| 134 | |
| 135 | void PoolAllocator::DeallocateRaw(void* ptr) { |
| 136 | if (ptr == nullptr) return; |
| 137 | ChunkPrefix* cp = FindPrefix(ptr); |
| 138 | CHECK_LE((void*)cp, (void*)ptr); |
| 139 | if (!has_size_limit_ && !auto_resize_) { |
| 140 | allocator_->Free(cp, cp->num_bytes); |
| 141 | } else { |
| 142 | mutex_lock lock(mutex_); |
| 143 | ++put_count_; |
| 144 | while (pool_.size() >= pool_size_limit_) { |
| 145 | EvictOne(); |
| 146 | } |
| 147 | PtrRecord* pr = new PtrRecord; |
| 148 | pr->num_bytes = cp->num_bytes; |
| 149 | pr->ptr = cp; |
| 150 | AddToList(pr); |
| 151 | pool_.insert(std::make_pair(cp->num_bytes, pr)); |
| 152 | } |
| 153 | } |
| 154 | |
| 155 | void PoolAllocator::Clear() { |
| 156 | if (has_size_limit_) { |
nothing calls this directly
no test coverage detected