summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2021-04-06 20:25:14 +0200
committerTyge Løvset <[email protected]>2021-04-06 20:25:14 +0200
commit91543562acc1db086be92cb840cc9f34855b4bcf (patch)
tree8d5f324a6bf2153bda571ddb952492df82da3ec8
parent45ce3baa80a1405e9e111e08f6c7f2a7aa1e99d0 (diff)
downloadSTC-modified-91543562acc1db086be92cb840cc9f34855b4bcf.tar.gz
STC-modified-91543562acc1db086be92cb840cc9f34855b4bcf.zip
Fixed rare happening bugs in clist_X_split() and clist_X_erase_at().
-rw-r--r--stc/clist.h7
1 files 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; \
} \