fix(allocation): fix ut

test=develop
panyx0718-patch-1
Yu Yang 7 years ago
parent c8f6e70ab4
commit 1cb7e7dda2

@ -36,7 +36,12 @@ void Allocator::Free(Allocation* allocation) { delete allocation; }
const char* BadAlloc::what() const noexcept { return msg_.c_str(); }
void AllocationDeleter::operator()(Allocation* allocation) const {
allocation->allocator()->Free(allocation);
auto* allocator = allocation->allocator();
if (allocator) {
allocator->Free(allocation);
} else {
delete allocation; // Compatible for legacy allocation.
}
}
} // namespace allocation

@ -41,6 +41,7 @@ void BufferedAllocator::FreeCache(size_t size) {
while (!allocations_.empty()) { // free the largest
auto it = --allocations_.end();
cur += it->second->size();
delete it->second.release();
allocations_.erase(it);
if (cur >= size) return;
}

Loading…
Cancel
Save