提交 1cb7e7dd 编写于 作者: Y Yu Yang

fix(allocation): fix ut

test=develop
上级 c8f6e70a
......@@ -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;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册