Changes in kernel/generic/include/adt/list.h [a74d0ad:07525cd] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/include/adt/list.h
ra74d0ad r07525cd 67 67 ((type *) (((void *)(link)) - list_link_to_void(&(((type *) NULL)->member)))) 68 68 69 #define list_foreach(list, iterator) \ 70 for (link_t *iterator = (list).head.next; \ 71 iterator != &(list).head; iterator = iterator->next) 69 #define list_foreach(list, member, itype, iterator) \ 70 for (itype *iterator = NULL; iterator == NULL; iterator = (itype *) 1) \ 71 for (link_t *_link = (list).head.next; \ 72 iterator = list_get_instance(_link, itype, member), \ 73 _link != &(list).head; _link = _link->next) 72 74 73 75 #define assert_link_not_used(link) \ … … 204 206 } 205 207 208 /** Get next item in list. 209 * 210 * @param link Current item link 211 * @param list List containing @a link 212 * 213 * @return Next item or NULL if @a link is the last item. 214 */ 215 static inline link_t *list_next(link_t *link, const list_t *list) 216 { 217 return (link->next == &list->head) ? NULL : link->next; 218 } 219 220 /** Get previous item in list. 221 * 222 * @param link Current item link 223 * @param list List containing @a link 224 * 225 * @return Previous item or NULL if @a link is the first item. 226 */ 227 static inline link_t *list_prev(link_t *link, const list_t *list) 228 { 229 return (link->prev == &list->head) ? NULL : link->prev; 230 } 231 206 232 /** Split or concatenate headless doubly-linked circular list 207 233 * … … 270 296 { 271 297 unsigned int cnt = 0; 272 273 list_foreach(*list, link) { 298 link_t *link; 299 300 link = list_first(list); 301 while (link != NULL) { 274 302 if (cnt == n) 275 303 return link; 276 304 277 305 cnt++; 306 link = list_next(link, list); 278 307 } 279 308
Note:
See TracChangeset
for help on using the changeset viewer.