summaryrefslogtreecommitdiffhomepage
path: root/include/stc/cstack.h
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2022-08-10 12:59:20 +0200
committerTyge Løvset <[email protected]>2022-08-10 12:59:20 +0200
commit1756309078f4c09765bde898e50b8a3078cebc7d (patch)
tree592e82f3ee6f064e2f889d3fde065761f5308bf1 /include/stc/cstack.h
parent90624d6d398ff1d0f79df3dd656c4ad0c9c498a9 (diff)
downloadSTC-modified-1756309078f4c09765bde898e50b8a3078cebc7d.tar.gz
STC-modified-1756309078f4c09765bde898e50b8a3078cebc7d.zip
Fixed cdeq, cvec, cmap and cstack: iterators .ref is now NULL when it is end(). clist and csmap/cset already has this property.
Diffstat (limited to 'include/stc/cstack.h')
-rw-r--r--include/stc/cstack.h6
1 files changed, 3 insertions, 3 deletions
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"