Skip to content

CF_LIST_NODE

Category: list
GitHub: cute_doubly_list.h


Converts a pointer to a host struct/object to a specific CF_ListNode member.

#define CF_LIST_NODE(T, member, ptr) ((CF_ListNode*)((uintptr_t)ptr + CF_OFFSET_OF(T, member)))
Parameters Description
T The type of the host.
member The name of the host member.
ptr A pointer to the host.

Return Value

Returns a pointer to a CF_ListNode.

Code Example

Converting from host to node pointer.

struct MyStruct {
    int a;
    float b;
    CF_ListNode node;
};

MyStruct x = get_struct();
CF_ListNode node = CF_LIST_NODE(MyStruct, node, &x);

// Do whatever is needed with the node.
do_stuff(node);

Remarks

This doubly-linked list is intrusive, meaning you place nodes inside of objects. These helper macros are to easily convert to/from host pointer and node pointer.

CF_ListNode
CF_List
cf_list_back
CF_LIST_HOST
cf_list_init_node
cf_list_init
cf_list_push_front
cf_list_push_back
cf_list_remove
cf_list_pop_front
cf_list_pop_back
cf_list_empty
cf_list_begin
cf_list_end
cf_list_front