util/SliceBuffer: move code to DiscardMemory()
This commit is contained in:
parent
2ec94c0497
commit
1702e98fdf
|
@ -87,6 +87,13 @@ public:
|
||||||
return n_allocated == buffer.size();
|
return n_allocated == buffer.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DiscardMemory() noexcept {
|
||||||
|
assert(empty());
|
||||||
|
|
||||||
|
n_initialized = 0;
|
||||||
|
buffer.Discard();
|
||||||
|
}
|
||||||
|
|
||||||
template<typename... Args>
|
template<typename... Args>
|
||||||
T *Allocate(Args&&... args) {
|
T *Allocate(Args&&... args) {
|
||||||
assert(n_initialized <= buffer.size());
|
assert(n_initialized <= buffer.size());
|
||||||
|
@ -131,9 +138,7 @@ public:
|
||||||
/* give memory back to the kernel when the last slice
|
/* give memory back to the kernel when the last slice
|
||||||
was freed */
|
was freed */
|
||||||
if (n_allocated == 0) {
|
if (n_allocated == 0) {
|
||||||
buffer.Discard();
|
DiscardMemory();
|
||||||
n_initialized = 0;
|
|
||||||
available = nullptr;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue