Preserve circular buffer item semantics - #93
Open
mjc wants to merge 2 commits into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates the circular buffer implementation so that operations consistently treat the underlying storage as item-sized records (not bytes), improving correctness for non-item_size == 1 buffers while keeping FIFO behavior unchanged.
Changes:
- Added input validation in
circular_buffer_push/circular_buffer_getto ignore invalid buffer/item pointers and zero-sized configurations. - Fixed indexed removal (
circular_buffer_pop) to shift whole items to preserve item semantics. - Fixed iteration to pass item-aligned pointers to callbacks.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
lukash
reviewed
Jul 19, 2026
mjc
force-pushed
the
refloat-fix-circular-buffer
branch
3 times, most recently
from
July 25, 2026 21:26
59bfc5f to
ab1fb35
Compare
Owner
|
Minor, the commit title "Circular buffer: Remove indexed items" doesn't make much sense, could you improve it? Besides that looks good now. |
mjc
force-pushed
the
refloat-fix-circular-buffer
branch
from
July 28, 2026 17:51
ab1fb35 to
2cd1ed0
Compare
Contributor
Author
|
should be all set now. sorry about the amount of churn, doing my best |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix two independent circular-buffer behaviors.
circular_buffer_iterate()previously used an item index as a byte offset. For buffers containing multi-byte records, callbacks after the first could therefore receive pointers inside another record. The index is now multiplied byitem_sizeso each callback receives a complete item. This fixes the experimental recorder plotting path, which iterates overSamplerecords.Following review feedback,
circular_buffer_pop()now implements a conventional FIFO pop: its unused index argument was removed, it copies the item at the tail, and then advances the tail. There are currently no callers requiring migration.The defensive argument guards and indexed-item shifting from earlier revisions were removed following review feedback.