参照元

説明

リストの先頭を指す専用の struct list_head がある? もしくは list_head は最後と最初が繋がっている循環リストなので、リストの最後の要素が分かっていても使えるかもしれない。

struct some {
    int data_foo;
    struct list_head list;
    int data_bar;
};
struct some some_list[N];

...

/* リストの先頭の要素が持ってる struct list_head */
struct list_head *some_list_first = &some_list[0].list;

/* リストの先頭の要素を指すためだけの struct list_head */
struct list_head some_list_head;
some_list_head.next = some_list_first;

...

struct some *some_first = list_first_entry(&some_list_head, struct some, list);

引数

返り値

参考

実装

/**
 * list_first_entry - get the first element from a list
 * @ptr:        the list head to take the element from.
 * @type:       the type of the struct this is embedded in.
 * @member:     the name of the list_head within the struct.
 *
 * Note, that list is expected to be not empty.
 */
#define list_first_entry(ptr, type, member) \
        list_entry((ptr)->next, type, member)

コメント


トップ   編集 凍結 差分 履歴 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS
Last-modified: 2016-04-07 (木) 11:56:16