From 1756309078f4c09765bde898e50b8a3078cebc7d Mon Sep 17 00:00:00 2001 From: Tyge Løvset Date: Wed, 10 Aug 2022 12:59:20 +0200 Subject: Fixed cdeq, cvec, cmap and cstack: iterators .ref is now NULL when it is end(). clist and csmap/cset already has this property. --- include/stc/cstack.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'include/stc/cstack.h') diff --git a/include/stc/cstack.h b/include/stc/cstack.h index 3986e366..811479c4 100644 --- a/include/stc/cstack.h +++ b/include/stc/cstack.h @@ -173,11 +173,11 @@ STC_INLINE _cx_iter _cx_memb(_begin)(const _cx_self* self) { return c_make(_cx_iter){self->size ? (_cx_value*)self->data : NULL, (_cx_value*)self->data + self->size}; } STC_INLINE _cx_iter _cx_memb(_end)(const _cx_self* self) - { return c_make(_cx_iter){NULL}; } + { return c_make(_cx_iter){NULL, (_cx_value*)self->data + self->size}; } STC_INLINE void _cx_memb(_next)(_cx_iter* it) { if (++it->ref == it->_end) it->ref = NULL; } -STC_INLINE _cx_iter _cx_memb(_advance)(_cx_iter it, intptr_t offs) - { it.ref += offs; return it; } +STC_INLINE _cx_iter _cx_memb(_advance)(_cx_iter it, size_t offs) + { if ((it.ref += offs) >= it._end) it.ref = NULL ; return it; } #include "template.h" -- cgit v1.2.3