Skip to content

Commit 4359426

Browse files
committed
Fix ring buffer behavior after becoming full
1 parent 3425951 commit 4359426

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

library.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"maintainer": true
1414
}
1515
],
16-
"version": "7.1.2",
16+
"version": "7.1.3",
1717
"frameworks": "*",
1818
"platforms": "*",
1919
"export": {

src/tiny_ring_buffer.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ void tiny_ring_buffer_remove(tiny_ring_buffer_t* self, void* element)
9090
memcpy(element, source, self->element_size);
9191

9292
self->tail = increment_with_wrap(initial_tail, self->capacity);
93+
self->full = false;
9394
}
9495
}
9596

test/tests/tiny_ring_buffer_test.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,18 @@ TEST(tiny_ring_buffer, should_give_the_correct_count_when_full)
9696
the_count_should_be(3);
9797
}
9898

99+
TEST(tiny_ring_buffer, should_give_the_correct_count_after_having_been_full)
100+
{
101+
given_initialization_with_element_size_and_count(sizeof(uint16_t), 3);
102+
103+
after_inserting_element<uint16_t>(111);
104+
after_inserting_element<uint16_t>(222);
105+
after_inserting_element<uint16_t>(333);
106+
after_removing_element<uint16_t>();
107+
after_removing_element<uint16_t>();
108+
the_count_should_be(1);
109+
}
110+
99111
TEST(tiny_ring_buffer, should_give_the_correct_count_after_overwriting)
100112
{
101113
given_initialization_with_element_size_and_count(sizeof(uint16_t), 3);

0 commit comments

Comments
 (0)