diff options
author | Max Kellermann <max@musicpd.org> | 2018-09-23 19:15:28 +0200 |
---|---|---|
committer | Max Kellermann <max@musicpd.org> | 2018-09-23 19:15:28 +0200 |
commit | 1702e98fdf63d0dcc2fc1fa95a668c48601c815a (patch) | |
tree | 62fa3aece55650195569f09c869731d6316d229d /src/util | |
parent | 2ec94c049738b9f324b96e1b34311f99222c15b4 (diff) |
util/SliceBuffer: move code to DiscardMemory()
Diffstat (limited to 'src/util')
-rw-r--r-- | src/util/SliceBuffer.hxx | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/util/SliceBuffer.hxx b/src/util/SliceBuffer.hxx index 55572c592..9b2afc98c 100644 --- a/src/util/SliceBuffer.hxx +++ b/src/util/SliceBuffer.hxx @@ -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(); } } }; |