list: list_last() function
authorMarko Kreen <markokr@gmail.com>
Thu, 24 Sep 2009 09:59:07 +0000 (12:59 +0300)
committerMarko Kreen <markokr@gmail.com>
Tue, 8 Dec 2009 12:03:18 +0000 (14:03 +0200)
usual/list.h

index f19024941bd699bab93f484fa624eee4cddb0dc4..5c460fcd78dd75556d1d9ae17d2dd6231a30ee7f 100644 (file)
@@ -78,7 +78,7 @@ static inline struct List *list_pop(struct List *list)
        return list_del(list->next);
 }
 
-/* remove first from list and return */
+/* get first elem from list */
 static inline struct List *list_first(const struct List *list)
 {
        if (list_empty(list))
@@ -86,6 +86,14 @@ static inline struct List *list_first(const struct List *list)
        return list->next;
 }
 
+/* get last elem from list */
+static inline struct List *list_last(const struct List *list)
+{
+       if (list_empty(list))
+               return NULL;
+       return list->prev;
+}
+
 /* remove first elem from list and return with casting */
 #define list_pop_type(list, typ, field) \
        (list_empty(list) ? NULL \