aboutsummaryrefslogtreecommitdiff
path: root/util/list.h
diff options
context:
space:
mode:
authorkartofen <kartofen.mail.0@protonmail.com>2025-09-13 15:24:28 +0300
committerkartofen <kartofen.mail.0@protonmail.com>2025-09-13 15:24:28 +0300
commitdb1b9c8dcb0d115217a33c2fe8e0760d49143e11 (patch)
treec93743adff3d78ea066c14879b7d2bfeb3ce42fb /util/list.h
parent46e786db9d1b48b8fbc3502e36f093b755f3e09f (diff)
ast nearly build and proper errors
Diffstat (limited to 'util/list.h')
-rw-r--r--util/list.h32
1 files changed, 3 insertions, 29 deletions
diff --git a/util/list.h b/util/list.h
index d9531ea..73eb900 100644
--- a/util/list.h
+++ b/util/list.h
@@ -5,16 +5,13 @@
#define container_of(ptr, type, member) ((type *)((char *)(ptr) - offsetof(type, member)))
struct list_head {
- struct list_head *prev;
struct list_head *next;
};
#define LIST_END NULL
-#define LIST_EMPTY(list) do { \
- (list)->next = LIST_END; \
- (list)->prev = LIST_END; \
- } while(0);
+#define LIST_EMPTY(list) (list)->next = LIST_END
+#define LIST_INIT_EMPTY() (struct list_head){.next = NULL}
#define list_entry(ptr, type, member) \
container_of(ptr, type, member)
@@ -35,44 +32,21 @@ struct list_head {
pos && (__next = pos->next,1); \
pos = __next)
-static inline int list_is_head(struct list_head *l)
-{
- return l->prev == LIST_END;
-}
-
static inline int list_is_tail(struct list_head *l)
{
return l->next == LIST_END;
}
-static inline struct list_head *list_get_head(struct list_head *l)
-{
- while(!list_is_head(l)) l = l->prev;
- return l;
-}
-
static inline struct list_head *list_get_tail(struct list_head *l)
{
while(!list_is_tail(l)) l = l->next;
return l;
}
-static inline struct list_head *list_add(
- struct list_head *head,
- struct list_head *new)
-{
- if(head) {
- // new->next = head->next;
- head->next = new;
- }
- new->prev = head;
- return new;
-}
-
static inline size_t list_len(struct list_head *head)
{
size_t n = 0;
- list_for_each(pos, list_get_head(head)) n++;
+ list_for_each(pos, head) n++;
return n;
}