From f943c8b7a6e46dc002ffc63c9fbcc111f6dca55d Mon Sep 17 00:00:00 2001 From: Tyge Løvset Date: Fri, 25 Mar 2022 07:35:21 +0100 Subject: Modified (more) rarely used macros c_apply_cnt(v, ..) and c_apply_arr(v, ..) so that v is a reference that may modify the container items. --- include/stc/ccommon.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/stc/ccommon.h b/include/stc/ccommon.h index 4034c0ce..4ee6cad0 100644 --- a/include/stc/ccommon.h +++ b/include/stc/ccommon.h @@ -200,14 +200,14 @@ STC_INLINE char* c_strnstrn(const char *s, const char *needle, size_t slen, cons } while (0) #define c_apply_arr(v, action, T, arr, n) do { \ typedef T _c_T; \ - const _c_T* _c_arr = arr; size_t _n = n; \ - for (size_t index = 0; index < _n; ++index) \ - { const _c_T v = _c_arr[index]; action; } \ + _c_T *_c_arr = arr; \ + for (size_t index = 0, _c_n = n; index < _c_n; ++index) \ + { _c_T *v = _c_arr + index; action; } \ } while (0) #define c_apply_cnt(v, action, C, ...) do { \ size_t index = 0; \ c_foreach (_it, C, __VA_ARGS__) \ - { const C##_value v = *_it.ref; action; ++index; } \ + { C##_value* v = _it.ref; action; ++index; } \ } while (0) #define c_pair(v) (v).first, (v).second -- cgit v1.2.3