Fix splice_at which was broken.

This commit is contained in:
Patrick Pelissier committed 2018-05-30 20:21:27 +02:00
1 parent 50fdea813b
commit c4548c4355
1 file changed
+15 -7
+15 -7
View File
@@ -470,17 +470,25 @@ typedef struct ilist_head_s {
ILISTI_CONTRACT(name, nlist); \ ILISTI_CONTRACT(name, nlist); \
ILISTI_CONTRACT(name, olist); \ ILISTI_CONTRACT(name, olist); \
assert (npos != NULL && opos != NULL); \ assert (npos != NULL && opos != NULL); \
assert (!M_C(name, _end_p)(opos)); \
/* npos may be end */ \
(void) olist, (void) nlist; \ (void) olist, (void) nlist; \
type *obj = M_C(name, _ref)(opos); \ type *obj = M_C(name, _ref)(opos); \
type *refObj = M_C(name, _ref)(npos); \ struct ilist_head_s *ref = npos->current; \
/* Set npos iterator to new position of object */ \ /* Remove object */ \
npos->previous = &refObj->name; \ M_C(name, _unlink)(obj); \
npos->current = &obj->name; \ /* Push 'obj' after 'ref' */ \
npos->next = refObj->name.next; \ struct ilist_head_s *next = ref->next; \
ref->next = &obj->name; \
obj->name.next = next; \
obj->name.prev = ref; \
next->prev = &obj->name; \
/* Move iterator in old list */ \ /* Move iterator in old list */ \
M_C(name, _next)(opos); \ M_C(name, _next)(opos); \
M_C(name, _unlink)(obj); \ /* Set npos iterator to new position of object */ \
M_C(name, _push_after)(refObj, obj); \ npos->previous = ref; \
npos->current = &obj->name; \
npos->next = next; \
ILISTI_CONTRACT(name, nlist); \ ILISTI_CONTRACT(name, nlist); \
ILISTI_CONTRACT(name, olist); \ ILISTI_CONTRACT(name, olist); \
} \ } \