[NSWI004] Getting a pointer to the item with a link.

Georgii Ekserdzhian gxrjan at gmail.com
Wed Sep 30 09:47:50 CEST 2020


Oh at first I thought that we need to print pointers to the *payload
structure* themselves, that's why I was confused, since I have no way of
knowing what structure is embedded in the list, but now I see that we need
to print just the *link *pointers.
Thank you.
Georgii Ekserdzhian


ср, 30 сент. 2020 г. в 09:42, Vojtech Horky <horky at d3s.mff.cuni.cz>:

> Hello.
>
> Dne 30. 09. 20 v 9:34 Georgii Ekserdzhian napsal(a):
> > Good morning,
> > I'm working on a %pL placeholder and I encountered some problems.
> > So I get a pointer to a list. I turn it's pointer into a string, that's
> > fine.
> > Now I need to get pointers to the items in that list.
> > I need to iterate them first.
> > That is done either by list_foreach() or I can do it just by jumping
> > pointers to links and getting a pointer to each item with list_item().
> > Both list_foreach() and list_item() require a type of a payload and a
> > name of a link variable.
> > In test cases it's a paw_t, but I suppose we need to make this work on
> > any structure.
> > I'm not sure how to make this generic.
>
> Your reasoning is completely correct.
>
> For this special case, we expect that you will iterate through the
> prev/next pointers manually because there is no way how to pass
> information about the actual payload type into your printf.
>
> For other cases, the list_foreach() is the right approach as you usually
> know the payload type.
>
> Cheers,
> - VH
> _______________________________________________
> NSWI004 mailing list
> NSWI004 at d3s.mff.cuni.cz
> https://d3s.mff.cuni.cz/mailman/listinfo/nswi004
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://d3s.mff.cuni.cz/pipermail/nswi004/attachments/20200930/ffba82ae/attachment.htm>


More information about the NSWI004 mailing list