diff options
author | Danny Holman <dholman@gymli.org> | 2024-02-16 12:30:49 -0600 |
---|---|---|
committer | Danny Holman <dholman@gymli.org> | 2024-02-16 12:30:49 -0600 |
commit | 1d40d14e09c8c22ffbdf5a5cad95ae552587ce53 (patch) | |
tree | ab419012553bbbb9b1589aafc8ea865cc9dc7daf | |
parent | 19b5c8699f0d201a8ffe41594d966d143320260d (diff) |
include: kernel: move list.h to a data struct directory
Move list.h into a designated directory for data structure definitions.
Signed-off-by: Danny Holman <dholman@gymli.org>
-rw-r--r-- | include/kernel/data/list.h (renamed from include/kernel/list.h) | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/include/kernel/list.h b/include/kernel/data/list.h index cc78a4f..b61cfaa 100644 --- a/include/kernel/list.h +++ b/include/kernel/data/list.h @@ -1,5 +1,5 @@ -#ifndef LIST_H -#define LIST_H +#ifndef KERNEL_LIST_H +#define KERNEL_LIST_H #include <stddef.h> @@ -9,12 +9,13 @@ struct list_head { }; static inline void list_add(struct list_head *new, struct list_head *head) { - new->prev = head; - new->next = head->next; + struct list_head *temp = head; + while (temp->next != NULL) + temp = temp->next; - head->next = new; - if (head->prev != NULL) - head->prev->next = new; + temp->next = new; + new->prev = temp; + new->next = NULL; } static inline void list_del(struct list_head *item) { |