Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
RIOT
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cm-projects
RIOT
Commits
b518f3c7
Unverified
Commit
b518f3c7
authored
6 years ago
by
Kaspar Schleiser
Committed by
GitHub
6 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #9869 from bergzand/pr/tsrb/drop
tsrb: add drop function
parents
ec5e4f8d
8d9cb25e
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
sys/include/tsrb.h
+8
-0
8 additions, 0 deletions
sys/include/tsrb.h
sys/tsrb/tsrb.c
+10
-0
10 additions, 0 deletions
sys/tsrb/tsrb.c
with
18 additions
and
0 deletions
sys/include/tsrb.h
+
8
−
0
View file @
b518f3c7
...
...
@@ -127,6 +127,14 @@ int tsrb_get_one(tsrb_t *rb);
*/
int
tsrb_get
(
tsrb_t
*
rb
,
char
*
dst
,
size_t
n
);
/**
* @brief Drop bytes from ringbuffer
* @param[in] rb Ringbuffer to operate on
* @param[in] n max number of bytes to drop
* @return nr of bytes dropped
*/
int
tsrb_drop
(
tsrb_t
*
rb
,
size_t
n
);
/**
* @brief Add a byte to ringbuffer
* @param[in] rb Ringbuffer to operate on
...
...
This diff is collapsed.
Click to expand it.
sys/tsrb/tsrb.c
+
10
−
0
View file @
b518f3c7
...
...
@@ -49,6 +49,16 @@ int tsrb_get(tsrb_t *rb, char *dst, size_t n)
return
(
n
-
tmp
);
}
int
tsrb_drop
(
tsrb_t
*
rb
,
size_t
n
)
{
size_t
tmp
=
n
;
while
(
tmp
&&
!
tsrb_empty
(
rb
))
{
_pop
(
rb
);
tmp
--
;
}
return
(
n
-
tmp
);
}
int
tsrb_add_one
(
tsrb_t
*
rb
,
char
c
)
{
if
(
!
tsrb_full
(
rb
))
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment