summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2020-09-17 09:09:38 +0200
committerTyge Løvset <[email protected]>2020-09-17 09:09:38 +0200
commit01426f1e82b60d319c3319391b43d84a8e613970 (patch)
tree327e25db9c25deb76a8d628d0abe90052c07bc9b
parentbd51beb42e83c1ed7a76bf673a537c9bd0c50e21 (diff)
downloadSTC-modified-01426f1e82b60d319c3319391b43d84a8e613970.tar.gz
STC-modified-01426f1e82b60d319c3319391b43d84a8e613970.zip
clist Iterator state bug fixed.
-rw-r--r--stc/clist.h9
1 files changed, 5 insertions, 4 deletions
diff --git a/stc/clist.h b/stc/clist.h
index d812fd12..8f7128b0 100644
--- a/stc/clist.h
+++ b/stc/clist.h
@@ -144,8 +144,8 @@ STC_API size_t _clist_size(const clist_void* self);
} \
STC_INLINE clist_##X##_iter_t \
clist_##X##_before_begin(const clist_##X* self) { \
- clist_##X##_value_t *before = self->last ? &self->last->value : NULL; \
- clist_##X##_iter_t it = {&self->last, before, -1}; return it; \
+ clist_##X##_value_t *last = self->last ? &self->last->value : NULL; \
+ clist_##X##_iter_t it = {&self->last, last, -1}; return it; \
} \
STC_INLINE clist_##X##_iter_t \
clist_##X##_begin(const clist_##X* self) { \
@@ -238,7 +238,7 @@ STC_API size_t _clist_size(const clist_void* self);
clist_##X##_node_t* node = pos.get ? _clist_node(X, pos.get) : NULL; \
_c_clist_insert_after(self, X, node, value); \
if (node == self->last && pos._state == 0) self->last = entry; \
- pos.get = &entry->value; return pos; \
+ pos.get = &entry->value, pos._state = 0; return pos; \
} \
STC_API clist_##X##_iter_t \
clist_##X##_erase_after(clist_##X* self, clist_##X##_iter_t pos) { \
@@ -248,7 +248,8 @@ STC_API size_t _clist_size(const clist_void* self);
STC_API clist_##X##_iter_t \
clist_##X##_erase_range_after(clist_##X* self, clist_##X##_iter_t first, clist_##X##_iter_t finish) { \
clist_##X##_node_t* node = _clist_node(X, first.get), *done = finish.get ? _clist_node(X, finish.get) : NULL; \
- while (node && node->next != done) node = _clist_##X##_erase_after(self, node); \
+ while (node && node->next != done) \
+ node = _clist_##X##_erase_after(self, node); \
clist_##X##_next(&first); return first; \
} \
\