Commit 1702e98f authored by Max Kellermann's avatar Max Kellermann

util/SliceBuffer: move code to DiscardMemory()

parent 2ec94c04
......@@ -87,6 +87,13 @@ public:
return n_allocated == buffer.size();
}
void DiscardMemory() noexcept {
assert(empty());
n_initialized = 0;
buffer.Discard();
}
template<typename... Args>
T *Allocate(Args&&... args) {
assert(n_initialized <= buffer.size());
......@@ -131,9 +138,7 @@ public:
/* give memory back to the kernel when the last slice
was freed */
if (n_allocated == 0) {
buffer.Discard();
n_initialized = 0;
available = nullptr;
DiscardMemory();
}
}
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment