Add list_add_head to libcutils

Adds a node to the head of the linked list.

Change-Id: I03fc81f348c5c4fdab8680928b6e353413e4bc3c
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Signed-off-by: Yong Yao <yong.yao@intel.com>
This commit is contained in:
Samuel Ortiz 2014-04-30 02:12:39 +02:00 committed by Yong Yao
parent 905874abe4
commit f8a1089ab5
1 changed files with 8 additions and 0 deletions

View File

@ -63,6 +63,14 @@ static inline void list_add_tail(struct listnode *head, struct listnode *item)
head->prev = item;
}
static inline void list_add_head(struct listnode *head, struct listnode *item)
{
item->next = head->next;
item->prev = head;
head->next->prev = item;
head->next = item;
}
static inline void list_remove(struct listnode *item)
{
item->next->prev = item->prev;