/* * llist.h * Generic linked list implementation in C */ #ifndef __LLIST_H__ #define __LLIST_H__ #include #include #include #define container_of(ptr, type, member) ({ \ const typeof( ((type *)0)->member ) *__mptr = (ptr); \ (type *)((char *)__mptr - offsetof(type,member));}) typedef struct ListNode{ void *data; struct ListNode *next; } ListNode; typedef ListNode * List; List *create_list(void *data); uint32_t list_size(List *list); List *list_add(List *list, void *data, uint32_t position); List *list_remove(List *list, uint32_t position); void list_delete(List *list); #endif /* __LLIST_H__ */