Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/lib/circular_buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ bool circular_buffer_get(const CircularBuffer *cb, size_t i, void *item) {
return true;
}

bool circular_buffer_pop(CircularBuffer *cb, size_t i, void *item) {
if (!circular_buffer_get(cb, i, item)) {
bool circular_buffer_pop(CircularBuffer *cb, void *item) {
if (!circular_buffer_get(cb, 0, item)) {
return false;
}

Expand All @@ -96,7 +96,7 @@ void circular_buffer_iterate(

size_t i = cb->tail;
do {
callback(&cb->buffer[i], data);
callback(cb->buffer + i * cb->item_size, data);
increment(cb, &i);
} while (i != cb->head);
}
7 changes: 3 additions & 4 deletions src/lib/circular_buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,10 @@ void circular_buffer_push(CircularBuffer *cb, const void *item);
bool circular_buffer_get(const CircularBuffer *cb, size_t i, void *item);

/**
* Pops an item at index i (a position relative to the current tail) from the
* buffer. If there's no item at that index, leaves item unchanged and returns
* false, otherwise returns true.
* Pops the item at the tail of the buffer. If the buffer is empty, leaves item
* unchanged and returns false, otherwise returns true.
*/
bool circular_buffer_pop(CircularBuffer *cb, size_t i, void *item);
bool circular_buffer_pop(CircularBuffer *cb, void *item);

/**
* Iterates over the buffer, calling the callback function on each item.
Expand Down
Loading