Add _reverse for I-LIST
This commit is contained in:
1 parent
46c2e33096
commit
4f3dad4bea
2 files changed
+23
No files matched your search
+16
@@ -570,6 +570,22 @@ typedef struct ilist_head_s {
|
||||
e->name.prev->next = &e->name; \
|
||||
ILISTI_CONTRACT(name, d); \
|
||||
ILISTI_CONTRACT(name, e); \
|
||||
} \
|
||||
\
|
||||
static inline void \
|
||||
M_C(name, _reverse)(list_t list) \
|
||||
{ \
|
||||
ILISTI_CONTRACT(name, list); \
|
||||
struct ilist_head_s *next, *it; \
|
||||
for(it = list->name.next ; it != &list->name; it = next) { \
|
||||
next = it->next; \
|
||||
it->next = it->prev; \
|
||||
it->prev = next; \
|
||||
} \
|
||||
next = it->next; \
|
||||
it->next = it->prev; \
|
||||
it->prev = next; \
|
||||
ILISTI_CONTRACT(name, list); \
|
||||
} \
|
||||
|
||||
#endif
|
||||
@@ -174,6 +174,13 @@ static void test2(void)
|
||||
n++;
|
||||
}
|
||||
assert (n == NUM);
|
||||
ilist_tname_reverse(list1);
|
||||
for M_EACH(item, list1, ILIST_OPLIST(ilist_tname)) {
|
||||
n--;
|
||||
assert (n == item->n);
|
||||
}
|
||||
assert (n == 0);
|
||||
|
||||
}
|
||||
M_LET(list1, list2, ILIST_OPLIST(ilist_tname)) {
|
||||
for(int i = 0; i < NUM; i++)
|
||||
|
||||
Reference in new issue
Block a user