summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSamuel Ortiz <sameo@linux.intel.com>2014-04-30 02:12:39 +0200
committerYong Yao <yong.yao@intel.com>2014-05-13 21:37:35 +0000
commitf8a1089ab5d3976c631cfe7b40eca8a5ed34c306 (patch)
tree853503d645883ddea93e693b95c8d8942267eb63
parent905874abe45279d7c668e590d404880dd91b1869 (diff)
downloadsystem_core-f8a1089ab5d3976c631cfe7b40eca8a5ed34c306.zip
system_core-f8a1089ab5d3976c631cfe7b40eca8a5ed34c306.tar.gz
system_core-f8a1089ab5d3976c631cfe7b40eca8a5ed34c306.tar.bz2
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>
-rw-r--r--include/cutils/list.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/include/cutils/list.h b/include/cutils/list.h
index 945729a..6e94ddf 100644
--- a/include/cutils/list.h
+++ b/include/cutils/list.h
@@ -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;