Update list implementation

This commit is contained in:
topjohnwu
2017-07-02 17:47:07 +08:00
parent 7b9be8369e
commit 9d421226a7
3 changed files with 29 additions and 12 deletions

View File

@@ -24,15 +24,19 @@ void list_insert_end(struct list_head *head, struct list_head *node) {
list_insert(head->prev, node);
}
void list_pop(struct list_head *pos) {
struct list_head *list_pop(struct list_head *pos) {
struct list_head *ret;
ret = pos->prev;
// Maintain the list
pos->prev->next = pos->next;
pos->next->prev = pos->prev;
// Remove references
pos->next = pos;
pos->prev = pos;
// Return the previous node in the list
return ret;
}
void list_pop_end(struct list_head *head) {
struct list_head *list_pop_end(struct list_head *head) {
return list_pop(head->prev);
}