Skip to content

Commit

Permalink
util/SliceBuffer: move code to DiscardMemory()
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxKellermann committed Sep 23, 2018
1 parent 2ec94c0 commit 1702e98
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/util/SliceBuffer.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down Expand Up @@ -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();
}
}
};
Expand Down

0 comments on commit 1702e98

Please sign in to comment.