Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New routine to find a node on a list #217

Merged
merged 1 commit into from
Oct 4, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions lib/list.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#ifndef __METAL_LIST__H__
#define __METAL_LIST__H__

#include <stdbool.h>
arnopo marked this conversation as resolved.
Show resolved Hide resolved
#include <stdlib.h>

#ifdef __cplusplus
Expand Down Expand Up @@ -96,6 +97,18 @@ static inline struct metal_list *metal_list_first(struct metal_list *list)
for ((node) = (list)->next; \
(node) != (list); \
(node) = (node)->next)

static inline bool metal_list_find_node(struct metal_list *list,
struct metal_list *node)
{
struct metal_list *n;

metal_list_for_each(list, n) {
if (n == node)
return true;
}
return false;
}
/** @} */

#ifdef __cplusplus
Expand Down