diff options
| author | Tyge Løvset <[email protected]> | 2021-04-06 17:47:05 +0200 |
|---|---|---|
| committer | Tyge Løvset <[email protected]> | 2021-04-06 17:47:05 +0200 |
| commit | 45ce3baa80a1405e9e111e08f6c7f2a7aa1e99d0 (patch) | |
| tree | d4d669c3b6cd37525f6e721e53775be379b2689b | |
| parent | 44adba28455e0e873480884b292fbe1d4b7763a5 (diff) | |
| download | STC-modified-45ce3baa80a1405e9e111e08f6c7f2a7aa1e99d0.tar.gz STC-modified-45ce3baa80a1405e9e111e08f6c7f2a7aa1e99d0.zip | |
Final fix for clist_X_split().
| -rw-r--r-- | stc/clist.h | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/stc/clist.h b/stc/clist.h index 31d6ec88..c424d439 100644 --- a/stc/clist.h +++ b/stc/clist.h @@ -305,14 +305,13 @@ STC_API size_t _clist_size(const clist_void* self); \
STC_DEF clist_##X \
clist_##X##_split(clist_##X* self, clist_##X##_iter_t pos1, clist_##X##_iter_t pos2) { \
- clist_##X##_node_t *p1 = pos1.ref ? pos1._prev : NULL, \
- *p2 = pos2.ref ? pos2._prev : self->last; \
clist_##X list = {NULL}; \
- if (p1 && p2) { \
- p1->next = p2->next, p2->next = _clist_node(X, pos1.ref); \
- if (self->last == p2) self->last = pos2.ref ? p1 : NULL; \
- list.last = p2; \
- } \
+ if (pos1.ref == pos2.ref) return list; \
+ clist_##X##_node_t *p1 = pos1._prev, \
+ *p2 = pos2.ref ? pos2._prev : self->last; \
+ p1->next = p2->next, p2->next = _clist_node(X, pos1.ref); \
+ if (self->last == p2) self->last = (p1 == p2) ? NULL : p1; \
+ list.last = p2; \
return list; \
} \
\
|
