Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
R
rdma-mwe
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Titouan Soulard
rdma-mwe
Commits
25ac2fde
Commit
25ac2fde
authored
Feb 06, 2024
by
Titouan Soulard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
common: fix a bug with finite circular buffers
parent
13856694
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
2 deletions
+11
-2
common/circular_buffer.c
common/circular_buffer.c
+11
-2
No files found.
common/circular_buffer.c
View file @
25ac2fde
...
...
@@ -32,8 +32,15 @@ void common_circular_buffer_write(struct CommonCBBuffer *buffer, void *bytes, ui
buffer
->
write_counter
+=
reduced_byte_count
;
}
// Finite buffers should have a mark of where to stop
if
(
buffer
->
readable_len
>=
0
)
buffer
->
readable_len
+=
byte_count
;
// Finite buffers point to the last available sample
if
(
buffer
->
readable_len
>=
0
)
{
buffer
->
readable_len
+=
byte_count
;
if
(
buffer
->
readable_len
>
buffer
->
total_len
)
{
printf
(
"circular_buffer: overflow, increase buffer size
\n
"
);
buffer
->
readable_len
=
0
;
}
}
}
uint32_t
common_circular_buffer_read
(
struct
CommonCBBuffer
*
buffer
,
void
*
bytes
,
uint32_t
user_count
)
{
...
...
@@ -54,6 +61,8 @@ uint32_t common_circular_buffer_read(struct CommonCBBuffer *buffer, void *bytes,
total_count
+=
read_count
;
}
if
(
buffer
->
readable_len
>=
0
)
buffer
->
readable_len
-=
total_count
;
return
total_count
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment