Skip to content

Conversation

sirknightj
Copy link
Contributor

@sirknightj sirknightj commented Nov 14, 2024

Issue #, if available:
N/A

What was changed?

  • Add proper size tracking (bug fix), which allows:
    • Able to check if it's at capacity and data will be overwritten.
    • DLOGI("Extract! Size: %d, index: %u, bounds: [%u - %u). Ago=%d", pRollingBuffer->size, index, pRollingBuffer->tailIndex, pRollingBuffer->headIndex, pRollingBuffer->headIndex - index); to check how many elements away from the head of the queue upon request.
  • Handle integer overflow case when indexes wrap around UINT64_MAX.
  • Add documentation for methods
  • Add comments in the code
  • Factored out the range check to a separate method.
  • Added more unit tests to confirm behavior.
  • Make rollingBufferGetSize and rollingBufferIsEmpty thread safe by adding locks.

Why was it changed?

  • Make rolling buffer code more robust and more readable.

How was it changed?

  • Refer to the code above.
  • Note: The size needed to be its own variable because you can remove items from the buffer in an arbitrary order.

What testing was done for the changes?

  • Run the new unit tests and they pass.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@sirknightj sirknightj changed the base branch from release-v1.12.0 to develop May 5, 2025 19:34
@sirknightj sirknightj changed the base branch from develop to release-v1.12.0 May 5, 2025 19:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant