如何打印双向链表的内容?

时间:2010-07-14 15:01:11

标签: c linux linux-kernel

如何使用list.h中定义的/include/linux/list.h打印列表值?

1 个答案:

答案 0 :(得分:2)

这样的事情:

struct list_head head; /* previously initialized */
struct list_head *pos;

list_for_each(pos, head)
{
    your_type *elt;
    elt = list_entry(pos, typeof(*elt), name_of_list_head_struct_member);
    /* and print *elt! */
}