Warning: mysqli_query(): (HY000/1021): Disk full (/tmp/#sql_51b_2.MAI); waiting for someone to free some space... (errno: 28 "No space left on device") in /opt/lampp/htdocs/wordpress/wp-includes/wp-db.php on line 2033
linux内核数据结构 — list_head()-LINUX – 知识波
       

linux内核数据结构 — list_head()

struct kobject {
    const char        *name;
    struct list_head    entry;
    struct kobject        *parent;
...
};
struct list_head {
    struct list_head *next, *prev;
};

初始化 struct list_head,其next和prev都指向自己

static inline void INIT_LIST_HEAD(struct list_head *list)
{
    WRITE_ONCE(list->next, list);
    WRITE_ONCE(list->prev, list);
}

head—>head

向链表尾添加条目

static inline void list_add_tail(struct list_head *new, struct list_head *head)
{
    __list_add(new, head->prev, head);
}

添加条目A后,head—>A—>head,添加条目B后,head—>A—>B—>head

遍历链表,取出 struct kobject 实例到 k,

        list_for_each_entry(k, &list, entry)
            xxx;
————————
struct kobject {
    const char        *name;
    struct list_head    entry;
    struct kobject        *parent;
...
};
struct list_head {
    struct list_head *next, *prev;
};

初始化 struct list_head,其next和prev都指向自己

static inline void INIT_LIST_HEAD(struct list_head *list)
{
    WRITE_ONCE(list->next, list);
    WRITE_ONCE(list->prev, list);
}

head—>head

向链表尾添加条目

static inline void list_add_tail(struct list_head *new, struct list_head *head)
{
    __list_add(new, head->prev, head);
}

添加条目A后,head—>A—>head,添加条目B后,head—>A—>B—>head

遍历链表,取出 struct kobject 实例到 k,

        list_for_each_entry(k, &list, entry)
            xxx;