[pacman-dev] alpm_list_last

Xavier shiningxc at gmail.com
Mon Apr 21 03:20:28 EDT 2008


On Mon, Apr 21, 2008 at 8:33 AM, Sebastian Nowicki <sebnow at gmail.com> wrote:
>
>  Ok, but there's also alpm_list_first and alpm_list_next. According to
>  your description alpm_list_first should be the same as alpm_list_next,
>  unless I misunderstood you.

You misunderstood.
What I was saying is illustrated by the implementation of
alpm_list_first, that is :
alpm_list_first(list) == list.

Because a list is just the head node.

> Since alpm_list_t is a node in a double
>  linked list, it is possible to be somewhere in the middle of a list.

It's a convention to use the head node when manipulating a list.
Otherwise, how would you know where the head is?
Besides, you must have this propriety : list->prev == tail
If you use a node in the middle of a list, this is simply not true.

>  Using alpm_list_last somewhere in a progrem, I would expect to go to
>  the absolute last node within the list in general. The doxygen comment
>  seems to suggest this as well, as it talks about a list in general,
>  and not the node (alpm_list_t). It just seems a bit confusing/
>  misleading to me, and possibly others looking at the documentation.
>

That's because most functions are made to work with list (== head
nodes), and not a middle node.
It's very simple really, I have the feeling that I make it look more
complicated than it really is.




More information about the pacman-dev mailing list