[ccan] Question on list module

David Collett david.collett at gmail.com
Tue Dec 14 10:40:09 EST 2010


Hi Richard,

If you require your object to belong to multiple lists *at the same
time*, you need to include a list_node in your object for each list
you wish to belong to, just give them different (e.g. descriptive)
names.

Dave

On Tue, Dec 14, 2010 at 10:09 AM, richard -rw- weinberger
<richard.weinberger at gmail.com> wrote:
> Hi!
>
> I'm using the list module. It is very nice.
> But now I'm facing a little problem.
> It seems that a list node can (by design) only be a member of one linked list.
> In my case i need to have list nodes which are present in many lists.
>
> E.g:
> struct _item {
>  struct list_node list;
>  // lots of data
> };
> struct _item i1;
>
> list_add(&h1, &i1.list);
> list_add(&h2, &i1.list);
> ...
> list_add(&hN, &i1.list);
>
>
> Does anyone know a trick how to achieve this?
> I really don't want to go back to "void *"-style linked lists...
>
> --
> Thanks,
> //richard
> _______________________________________________
> ccan mailing list
> ccan at lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/ccan
>


More information about the ccan mailing list