Merge pull request #26678 from yuwata/foreach_array

macro: introduce FOREACH_ARRAY() macro
This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2023-03-08 19:06:20 +01:00
committed by GitHub
3 changed files with 70 additions and 13 deletions
+7
View File
@@ -297,6 +297,13 @@ static inline int __coverity_check_and_return__(int condition) {
p != (typeof(p)) POINTER_MAX; \
p = *(++_l))
#define _FOREACH_ARRAY(i, array, num, m, s) \
for (typeof(num) m = (num); m > 0; m = 0) \
for (typeof(array[0]) *s = (array), *i = s; s && i < s + m; i++)
#define FOREACH_ARRAY(i, array, num) \
_FOREACH_ARRAY(i, array, num, UNIQ_T(m, UNIQ), UNIQ_T(s, UNIQ))
#define DEFINE_TRIVIAL_DESTRUCTOR(name, type, func) \
static inline void name(type *p) { \
func(p); \