1 /* EINA - EFL data type library
2  * Copyright (C) 2002-2008 Carsten Haitzler, Vincent Torri, Jorge Luis Zapata Muga
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library;
16  * if not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #ifndef EINA_LIST_INLINE_H_
20 #define EINA_LIST_INLINE_H_
21 
22 static inline Eina_List *
eina_list_last(const Eina_List * list)23 eina_list_last(const Eina_List *list)
24 {
25    if (list) return list->accounting->last;
26    return NULL;
27 }
28 
29 static inline Eina_List *
eina_list_next(const Eina_List * list)30 eina_list_next(const Eina_List *list)
31 {
32    if (list) return list->next;
33    return NULL;
34 }
35 
36 static inline Eina_List *
eina_list_prev(const Eina_List * list)37 eina_list_prev(const Eina_List *list)
38 {
39    if (list) return list->prev;
40    return NULL;
41 }
42 
43 static inline void *
eina_list_data_get(const Eina_List * list)44 eina_list_data_get(const Eina_List *list)
45 {
46    if (list) return list->data;
47    return NULL;
48 }
49 
50 static inline void *
eina_list_data_set(Eina_List * list,const void * data)51 eina_list_data_set(Eina_List *list, const void *data)
52 {
53    if (list)
54      {
55         void *tmp = list->data;
56         list->data = (void *) data;
57         return tmp;
58      }
59    return NULL;
60 }
61 
62 static inline unsigned int
eina_list_count(const Eina_List * list)63 eina_list_count(const Eina_List *list)
64 {
65    if (list) return list->accounting->count;
66    return 0;
67 }
68 
69 static inline void *
eina_list_last_data_get(const Eina_List * list)70 eina_list_last_data_get(const Eina_List *list)
71 {
72    if (list) return eina_list_data_get(eina_list_last(list));
73    return NULL;
74 }
75 
76 #endif /* EINA_LIST_INLINE_H_ */
77