[pacman-dev] alpm_list_last

Xavier shiningxc at gmail.com
Mon Apr 21 02:04:28 EDT 2008


Sebastian Nowicki wrote:
> I noticed that alpm_list_last simply returns a pointer to the previous  
> node. Is this expected behavior? My interpretation of "last" would be  
> to return the absolute last node, as the comment suggests. In my  
> opinion the function as it is now should be called alpm_list_prev.
> 
>  From alpm_list.c:
>> alpm_list_t SYMEXPORT *alpm_list_last(const alpm_list_t *list)
>> {
>> 	if(list) {
>> 		return(list->prev);
>> 	} else {
>> 		return(NULL);
>> 	}
>> }
> 

That's because a alpm_list_t element is not really a list, but a list node.
So when you use a list in alpm (with alpm_list_t *list), it's actually 
just the head node that you manipulate.
And head->prev == tail.




More information about the pacman-dev mailing list