From aaa3d7f6a107a668b1f24d8ed061fe74237d9883 Mon Sep 17 00:00:00 2001 From: Tyge Løvset Date: Thu, 3 Sep 2020 11:25:07 +0200 Subject: Changed itval() taking iter instead of iter address as arg. --- examples/stack.c | 2 ++ stc/clist.h | 2 +- stc/cmap.h | 2 +- stc/cqueue.h | 2 +- stc/cstack.h | 2 +- stc/cstr.h | 2 +- stc/cvec.h | 2 +- 7 files changed, 8 insertions(+), 6 deletions(-) diff --git a/examples/stack.c b/examples/stack.c index 2aa8364b..321228a2 100644 --- a/examples/stack.c +++ b/examples/stack.c @@ -14,5 +14,7 @@ int main() { for (int i=0; i<90; ++i) cstack_i_pop(&stack); + c_foreach (i, cstack_i, stack) + printf("%d\n", *cstack_i_itval(i)); printf("top: %d\n", *cstack_i_top(&stack)); } \ No newline at end of file diff --git a/stc/clist.h b/stc/clist.h index bbf05201..39479a09 100644 --- a/stc/clist.h +++ b/stc/clist.h @@ -146,7 +146,7 @@ STC_API size_t _clist_size(const clist_void* self); it->item = it->item->next; \ } \ STC_INLINE clist_##tag##_value_t* \ - clist_##tag##_itval(clist_##tag##_iter_t* it) {return &it->item->value;} \ + clist_##tag##_itval(clist_##tag##_iter_t it) {return &it.item->value;} \ \ STC_API clist_##tag##_iter_t \ clist_##tag##_insert_after_v(clist_##tag* self, clist_##tag##_iter_t pos, Value value); \ diff --git a/stc/cmap.h b/stc/cmap.h index bffa19c0..615ab7cb 100644 --- a/stc/cmap.h +++ b/stc/cmap.h @@ -250,7 +250,7 @@ ctype##_##tag##_next(ctype##_##tag##_iter_t* it) { \ while ((++it->item, *++it->_hx == 0)) ; \ } \ CMAP_ONLY_##ctype( STC_INLINE ctype##_##tag##_value_t* \ -ctype##_##tag##_itval(ctype##_##tag##_iter_t* it) {return &it->item->value;} ) \ +ctype##_##tag##_itval(ctype##_##tag##_iter_t it) {return &it.item->value;} ) \ \ STC_API uint32_t c_default_hash16(const void *data, size_t len); \ STC_API uint32_t c_default_hash32(const void* data, size_t len); \ diff --git a/stc/cqueue.h b/stc/cqueue.h index b69092d6..824f70dc 100644 --- a/stc/cqueue.h +++ b/stc/cqueue.h @@ -97,7 +97,7 @@ cqueue_##tag##_begin(cqueue_##tag* self) {return ctype##_begin(self);} \ STC_INLINE void \ cqueue_##tag##_next(cqueue_##tag##_iter_t* it) {ctype##_next(it);} \ STC_INLINE cqueue_##tag##_value_t* \ -cqueue_##tag##_itval(cqueue_##tag##_iter_t* it) {return ctype##_itval(it);} \ +cqueue_##tag##_itval(cqueue_##tag##_iter_t it) {return ctype##_itval(it);} \ \ typedef int cqueue_##tag##_dud diff --git a/stc/cstack.h b/stc/cstack.h index 1f8c8a4f..d90eee4e 100644 --- a/stc/cstack.h +++ b/stc/cstack.h @@ -84,7 +84,7 @@ cstack_##tag##_begin(cstack_##tag* self) {return ctype##_begin(self);} \ STC_INLINE void \ cstack_##tag##_next(cstack_##tag##_iter_t* it) {ctype##_next(it);} \ STC_INLINE cstack_##tag##_value_t* \ -cstack_##tag##_itval(cstack_##tag##_iter_t* it) {return ctype##_itval(it);} \ +cstack_##tag##_itval(cstack_##tag##_iter_t it) {return ctype##_itval(it);} \ \ typedef int cstack_##tag##_dud diff --git a/stc/cstr.h b/stc/cstr.h index 734087dc..f4d7bea3 100644 --- a/stc/cstr.h +++ b/stc/cstr.h @@ -111,7 +111,7 @@ cstr_begin(cstr_t* self) { cstr_iter_t it = {self->str, self->str + cstr_size(*self)}; return it; } STC_INLINE void cstr_next(cstr_iter_t* it) { ++it->item; } -STC_INLINE char* cstr_itval(cstr_iter_t* it) {return it->item;} +STC_INLINE char* cstr_itval(cstr_iter_t it) {return it.item;} STC_INLINE cstr_t* cstr_assign(cstr_t* self, const char* str) { diff --git a/stc/cvec.h b/stc/cvec.h index c94757d8..7a753b70 100644 --- a/stc/cvec.h +++ b/stc/cvec.h @@ -147,7 +147,7 @@ cvec_##tag##_begin(cvec_##tag* vec) { \ STC_INLINE void \ cvec_##tag##_next(cvec_##tag##_iter_t* it) { ++it->item; } \ STC_INLINE cvec_##tag##_value_t* \ -cvec_##tag##_itval(cvec_##tag##_iter_t* it) {return it->item;} \ +cvec_##tag##_itval(cvec_##tag##_iter_t it) {return it.item;} \ \ implement_cvec_7(tag, Value, valueDestroy, RawValue, valueCompareRaw, valueToRaw, valueFromRaw) -- cgit v1.2.3