-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlist.h
More file actions
40 lines (29 loc) · 835 Bytes
/
list.h
File metadata and controls
40 lines (29 loc) · 835 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/*
* SPDX-License-Identifier: GPL-2.0+
* Copyright (C) 2018 Abinav Puthan Purayil
* */
#ifndef LISTH
#define LISTH
#include "util.h"
struct list_node {
void *data;
size_t sz_data;
void *key;
size_t sz_key;
struct list_node *prev;
struct list_node *next;
};
#define LIST_NEW_NODE zalloc(sizeof(struct list_node))
#define LIST_INIT_HEAD(head) \
do { \
(head)->next = (head); \
(head)->prev = (head); \
} while (0);
#define list_for_each(i, head) \
for (i = (head)->next; i != (head); i = i->next)
extern void list_node_add(struct list_node *new,
struct list_node *prev, struct list_node *next);
extern void list_node_append(struct list_node *at, struct list_node *new);
extern void list_node_prepend(struct list_node *at, struct list_node *new);
extern void list_node_rm(struct list_node *target);
#endif