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
7c7bb45c
Commit
7c7bb45c
authored
7 years ago
by
Kaspar Schleiser
Browse files
Options
Downloads
Patches
Plain Diff
core/clist: make clist_foreach() return break-causing node
parent
b11b8064
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
core/include/clist.h
+14
-10
14 additions, 10 deletions
core/include/clist.h
with
14 additions
and
10 deletions
core/include/clist.h
+
14
−
10
View file @
7c7bb45c
...
...
@@ -325,24 +325,28 @@ static inline clist_node_t *clist_remove(clist_node_t *list, clist_node_t *node)
* The pointer supplied by @p arg will be passed to every call to @p func.
*
* If @p func returns non-zero, traversal will be aborted like when calling
* break within a for loop.
* break within a for loop
, returning the corresponding node
.
*
* @param[in] list List to traverse.
* @param[in] func Function to call for each member.
* @param[in] arg Pointer to pass to every call to @p func
*
* @returns NULL on empty list or full traversal
* @returns node that caused @p func(node, arg) to exit non-zero
*/
static
inline
void
clist_foreach
(
clist_node_t
*
list
,
int
(
*
func
)(
clist_node_t
*
,
void
*
),
void
*
arg
)
static
inline
clist_node_t
*
clist_foreach
(
clist_node_t
*
list
,
int
(
*
func
)(
clist_node_t
*
,
void
*
),
void
*
arg
)
{
clist_node_t
*
node
=
list
->
next
;
if
(
!
node
)
{
return
;
if
(
node
)
{
do
{
node
=
node
->
next
;
if
(
func
(
node
,
arg
))
{
return
node
;
}
}
while
(
node
!=
list
->
next
);
}
do
{
node
=
node
->
next
;
if
(
func
(
node
,
arg
))
{
return
;
}
}
while
(
node
!=
list
->
next
);
return
NULL
;
}
/**
...
...
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