Skip to content

Hash list

include/structures/hlist.h View source View on GitHub
struct hlist_head {
    struct hlist_node  *first;
};
struct hlist_node {
    struct hlist_node  *next;
    struct hlist_node  **pprev;
};
void INIT_HLIST_NODE(struct hlist_node *h);
bool hlist_unhashed(const struct hlist_node *h);
bool hlist_empty(const struct hlist_head *h);
void hlist_add_before(struct hlist_node *n, struct hlist_node *next);
void hlist_add_head(struct hlist_node *n, struct hlist_head *h);
void hlist_del(struct hlist_node *n);
void hlist_move_list(struct hlist_head *old, struct hlist_head *new);
struct hlist_node hlist_pop_head(struct hlist_head *h);
#define HLIST_HEAD_INIT {.first = NULL}
#define INIT_HLIST_HEAD(ptr) ((ptr)->first = NULL)
#define hlist_entry(ptr, type, member) container_of(ptr, type, member)
#define hlist_for_each_entry(pos, head, member) \
    for (pos = hlist_entry((head)->first, typeof(*pos), member); pos; \
         pos = hlist_entry(pos->member.next, typeof(*pos), member))