相关疑难解决方法(0)

正确加入两个双链表的方法

在Linux内核源代码中,list_splice实现了__list_splice:

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

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

        last->next = next;
        next->prev = last;
}
Run Code Online (Sandbox Code Playgroud)

是不是list已经指向链表的头部了?为什么我们需要list->next取而代之?

c linked-list linux-kernel

8
推荐指数
1
解决办法
259
查看次数

标签 统计

c ×1

linked-list ×1

linux-kernel ×1