Skip to content

Commit

Permalink
circular buffer bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
profezzorn committed Dec 1, 2023
1 parent ff81e54 commit 2643774
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions common/circular_buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ class CircularBuffer {
T& next() { return data_[first_.get() % SIZE]; }

size_t size() const { return first_.get() - last_.get(); }
bool empty() const { size() == 0; }
bool empty() const { return size() == 0; }
size_t space_available() const { return SIZE - size(); }
size_t continuous_space() const {
return std::min<size_t>(space_available(), SIZE - last_.get() % SIZE);
return std::min<size_t>(space_available(), SIZE - first_.get() % SIZE);
}
size_t continuous_data() const {
return std::min<size_t>(size(), SIZE - first_.get() % SIZE);
return std::min<size_t>(size(), SIZE - last_.get() % SIZE);
}

void push() { first_ += 1; }
Expand Down

0 comments on commit 2643774

Please sign in to comment.