This is a macro that is used to declare a structure type with the next and prev pointers for instances of the second structure type. This second type may be the parent type, so you can create a “linked structure” like this:
struct foo { LIST_ENTRY(foo) list; int value; };
This creates a struct foo containing an element named list , which in turn is the structure in question, pointers pointing to struct foo .
Now we can create a slightly related list of struct foo like this:
struct foo fa, fb; fa.value = 47; fa.list.le_next = &fb; fa.list.le_prev = NULL; fb.value = 11; fb.list.le_next = NULL; fb.list.le_prev = &fa.list.le_next;
I am not 100% sure on the last line, but I think it makes sense.
source share