Start of a structure.
This commit is contained in:
24
list.c
Normal file
24
list.c
Normal file
@@ -0,0 +1,24 @@
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "list.h"
|
||||
|
||||
void list_head_init(struct list_head *head) {
|
||||
head->next = head->prev = head;
|
||||
}
|
||||
|
||||
bool list_is_empty(const struct list_head *head) {
|
||||
return head->next == head;
|
||||
}
|
||||
|
||||
void list_add(struct list_head *new, struct list_head *head) {
|
||||
new->next = head;
|
||||
new->prev = head->prev;
|
||||
new->prev->next = new;
|
||||
head->prev = new;
|
||||
}
|
||||
|
||||
void list_del(struct list_head *entry) {
|
||||
entry->next->prev = entry->prev;
|
||||
entry->prev->next = entry->next;
|
||||
entry->prev = entry->next = NULL;
|
||||
}
|
||||
Reference in New Issue
Block a user