Intrusive List¶
Todo
Check for typeof()
availability.
Types¶
-
type ymo_list_head_t¶
Generic list datastructure.
typedef struct ymo_list_head ymo_list_head_t;
-
struct ymo_list_head¶
Simple linked list head structure.
struct ymo_list_head { struct ymo_list_head* next; struct ymo_list_head* prev; };
Functions¶
-
static inline void ymo_list_insert(ymo_list_head_t *prev, ymo_list_head_t *current, ymo_list_head_t *next)¶
Insert an item into a list between
prev
andnext
(both of which may be null).
-
static inline const ymo_list_head_t *ymo_list_next(const ymo_list_head_t *head)¶
Get the next item in a list.
-
static inline const ymo_list_head_t *ymo_list_prev(const ymo_list_head_t *head)¶
Get the previous item in a list.
Type-generic Macros¶
-
YMO_LIST_HEAD_M¶
Insert a list into a structure, using a specific name.
typedef struct my_type { YMO_LIST_HEAD_M(head); char my_data[100]; } my_type_t;
#define YMO_LIST_HEAD_M(name) \ ymo_list_head_t name
-
YMO_LIST_HEAD¶
YMO_LIST_HEAD_M using a generic name.
(See
YMO_LIST_HEAD_M
)#define YMO_LIST_HEAD() \ ymo_list_head_t YMO_LIST_NAME_DEFAULT
-
YMO_LIST_INIT_M¶
Initialize a list head object.
my_type_t my_obj; YMO_LIST_INIT_M(&my_obj, head);
#define YMO_LIST_INIT_M(p, m) \ ((p)->m->prev = (p)->m->next = NULL)
-
YMO_LIST_INIT¶
YMO_LIST_INIT_M using a generic name.
(See
YMO_LIST_INIT_M
)#define YMO_LIST_INIT(p) \ YMO_LIST_INIT_M(p, YMO_LIST_NAME_DEFAULT)
-
YMO_LIST_APPEND_M¶
Append an item to c list.
my_type_t c; my_type_t n; YMO_LIST_INIT(&c, head); YMO_LIST_INIT(&n, head); YMO_LIST_APPEND_M(&c, &n, head);
#define YMO_LIST_APPEND_M(c, n, m) \ ymo_list_insert(&c->m, &n->m, NULL)
-
YMO_LIST_APPEND¶
YMO_LIST_APPEND_M using c generic name.
(See
YMO_LIST_APPEND_M
)#define YMO_LIST_APPEND(c, n) \ YMO_LIST_APPEND_M(c, n, YMO_LIST_NAME_DEFAULT)
-
YMO_LIST_INSERT_M¶
#define YMO_LIST_INSERT_M(p, c, n, m) \ ymo_list_insert(p->m, c->m, n->m)
-
YMO_LIST_INSERT¶
YMO_LIST_INSERT_M using a generic name.
(See
YMO_LIST_INSERT_M
)#define YMO_LIST_INSERT(p, c, n) \ YMO_LIST_INSERT_M(p, c, n, YMO_LIST_NAME_DEFAULT)
-
YMO_LIST_NEXT_M¶
#define YMO_LIST_NEXT_M(p, t, m) \ ((t*)(((YMO_LIST_PTR_AR_TYPE)ymo_list_next(&p->m)) - offsetof(t,m)))
-
YMO_LIST_NEXT¶
YMO_LIST_NEXT_M using a generic name.
(See
YMO_LIST_NEXT_M
)#define YMO_LIST_NEXT(p, t) \ YMO_LIST_NEXT_M(p, t, YMO_LIST_NAME_DEFAULT)
-
YMO_LIST_PREV_M¶
#define YMO_LIST_PREV_M(p, t, m) \ ((t*)(((YMO_LIST_PTR_AR_TYPE)ymo_list_prev(&p->m)) - offsetof(t,m)))
-
YMO_LIST_PREV¶
YMO_LIST_PREV_M using a generic name.
(See
YMO_LIST_PREV_M
)#define YMO_LIST_PREV(p, t) \ YMO_LIST_PREV_M(p, t, YMO_LIST_NAME_DEFAULT)
-
YMO_LIST_LAST_M¶
#define YMO_LIST_LAST_M(c, t, m) \ ((t*)(((YMO_LIST_PTR_AR_TYPE)ymo_list_last(&c->m)) - offsetof(t,m)))
-
YMO_LIST_LAST¶
YMO_LIST_LAST_M using a generic name.
(See
YMO_LIST_LAST_M
)#define YMO_LIST_LAST(c, t) \ YMO_LIST_LAST_M(c, t, YMO_LIST_NAME_DEFAULT)