add list_concat, list_move, list_reverse

This commit is contained in:
Vincent Wei
2019-03-26 11:24:06 +08:00
parent d09313407e
commit c890e4296a
+31
View File
@@ -145,6 +145,37 @@ static inline int list_empty(const struct list_head *head)
return head->next == head;
}
/**
* list_concat - concatenate the entries from a list to another list.
* @src: the source list; the entries in the source list will be deleted.
* @dest: the destination list.
*/
static inline void list_concat(struct list_head* dest, struct list_head* src)
{
while (!list_empty(src)) {
struct list_head* entry = src->next;
list_del(src->next);
list_add_tail(entry, dest);
}
}
/**
* list_move - move the entries from a list to another list.
* @src: the source list; the entries in the source list will be deleted.
* @dest: the destination list, the list will be initialized to empty
* before moving the entries.
*/
static inline void list_move(struct list_head* dest, struct list_head* src)
{
INIT_LIST_HEAD(dest);
while (!list_empty(src)) {
struct list_head* entry = src->next;
list_del(src->next);
list_add_tail(entry, dest);
}
}
/**
* list_entry - get the struct for this entry
* @ptr: the &struct list_head pointer.