现在的位置: 首页 > 综合 > 正文

list_splice_tail

2013年08月15日 ⁄ 综合 ⁄ 共 548字 ⁄ 字号 评论关闭
/**
 * list_splice_tail - join two lists, each list being a queue
 * @list: the new list to add.
 * @head: the place to add it in the first list.
 */
static inline void list_splice_tail(struct list_head *list,
				struct list_head *head)
{
	if (!list_empty(list))
		__list_splice(list, head->prev, head);
}

static inline void __list_splice(const struct list_head *list,
				 struct list_head *prev,
				 struct list_head *next)
{
	struct list_head *first = list->next;
	struct list_head *last = list->prev;

	first->prev = prev;
	prev->next = first;

	last->next = next;
	next->prev = last;
}

拼接完链表如下:list从后往前接入

head->prev <=> list->next <=> list <=> list->prev <=> head

抱歉!评论已关闭.