Last active
April 8, 2018 15:41
-
-
Save kyoungho-koo/077fafdb45775d1522c5dae194b0adef to your computer and use it in GitHub Desktop.
linked list
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct list_elem | |
{ | |
struct list_elem *prev; | |
struct list_elem *next; | |
}; | |
struct list | |
{ | |
struct list_elem head; | |
struct list_elem tail; | |
}; | |
#define offsetof(TYPE,MEMBER) ((size_t)&((TYPE*)0)->MEMBER) | |
#define list_entry(LIST_ELEM,STRUCT,MEMBER) \ | |
( (STRUCT*)( (uin8_t*)&(LIST_ELEM)->next - offsetof(STRUCT,MEMBER,next) ) ) | |
#define LIST_INITIALIZER(NAME) { { NULL, &(NAME).tail }, \ | |
{ &(NAME).head, NULL } } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment