From 91543562acc1db086be92cb840cc9f34855b4bcf Mon Sep 17 00:00:00 2001 From: Tyge Løvset Date: Tue, 6 Apr 2021 20:25:14 +0200 Subject: Fixed rare happening bugs in clist_X_split() and clist_X_erase_at(). --- stc/clist.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/stc/clist.h b/stc/clist.h index c424d439..170e2dc5 100644 --- a/stc/clist.h +++ b/stc/clist.h @@ -250,7 +250,8 @@ STC_API size_t _clist_size(const clist_void* self); } \ STC_DEF clist_##X##_iter_t \ clist_##X##_erase_range(clist_##X* self, clist_##X##_iter_t first, clist_##X##_iter_t finish) { \ - clist_##X##_node_t* node = first._prev, *done = finish.ref ? _clist_node(X, finish.ref) : NULL; \ + clist_##X##_node_t *node = first.ref ? first._prev : NULL, \ + *done = finish.ref ? _clist_node(X, finish.ref) : NULL; \ while (node && node->next != done) \ node = _clist_##X##_erase_after(self, node); \ return finish; \ @@ -295,10 +296,10 @@ STC_API size_t _clist_size(const clist_void* self); if (!self->last) \ self->last = other->last; \ else if (other->last) { \ - clist_##X##_node_t *p = pos._prev ? pos._prev : self->last, *next = p->next; \ + clist_##X##_node_t *p = pos.ref ? pos._prev : self->last, *next = p->next; \ p->next = other->last->next; \ other->last->next = next; \ - if (!pos._prev) self->last = other->last; \ + if (!pos.ref) self->last = other->last; \ } \ other->last = NULL; \ } \ -- cgit v1.2.3