diff options
| author | Kimplul <kimi.h.kuparinen@gmail.com> | 2025-10-16 17:47:13 +0300 |
|---|---|---|
| committer | Kimplul <kimi.h.kuparinen@gmail.com> | 2025-10-16 17:47:13 +0300 |
| commit | 2176169257505d22021fc9a739c9f2090c514cb4 (patch) | |
| tree | b59a167a0792cff3856f135edffa3493cc450886 /include | |
| parent | 7ad6716b5c4dcf8c1c2ce8059884d26fa7c32908 (diff) | |
| download | conts-2176169257505d22021fc9a739c9f2090c514cb4.tar.gz conts-2176169257505d22021fc9a739c9f2090c514cb4.zip | |
check iteration on empty vectors
Diffstat (limited to 'include')
| -rw-r--r-- | include/conts/spvec.h | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/include/conts/spvec.h b/include/conts/spvec.h index 4fffb4a..d557fa8 100644 --- a/include/conts/spvec.h +++ b/include/conts/spvec.h @@ -193,6 +193,13 @@ static inline void SPVEC(shrink)(struct SPVEC_STRUCT *v, size_t n) static inline SPVEC_ITER SPVEC(begin)(struct SPVEC_STRUCT *v) { + if (v->n == 0) { + return (SPVEC_ITER) { + .i = 0, + .v = NULL + }; + } + return (SPVEC_ITER){ .i = 0, .v = SPVEC(at)(v, 0) |
