Pages

2010-09-13

Linux: Managing double linked list in the Linux kernel

 #include <linux/list.h>
  • LIST_HEAD(list_name): Creat an new double linked list.
  • list_add(n,p): Inserts an element pointed to by n right after the specified element pointed to by p. To insert n at the beginning of the list, set p to the address of the list head.
  • list_add_tail(n,p): Inserts an element pointed to by n right before the specified element pointed to by p. To insert n at the end of the list, set p to the address of the list head.
  • list_del(p): Deletes an element pointed to by p.
  • list_empty(p): Checks if the list specified by the address p of its head is empty.
  • list_entry(p,t,m): Returns the address of the data structure of type t in which the list_head field that has the name m and the address p is included.
  • list_for_each(p,h): Scans the elements of the list specified by the address h of the head; in each iteration, a pointer to the list_head structure of the list element is returned in p.
  • list_for_each_entry(p,h,m): Returns the address of the data structure embedding the list_head structure rather than the address of the list_head structure itself.

    No comments:

    Post a Comment