common/array.h: add macro `foreach_reverse`
Ref: https://github.com/awesomeWM/awesome/pull/340
This commit is contained in:
parent
292b95da01
commit
3cd0bb5783
|
@ -50,6 +50,15 @@
|
|||
(var = &(array).tab[__foreach_index_##var]); \
|
||||
++__foreach_index_##var)
|
||||
|
||||
#define foreach_reverse(var, array) \
|
||||
for(int __foreach_index_##var = (array).len-1; \
|
||||
__foreach_index_##var > -1; \
|
||||
__foreach_index_##var = -1) \
|
||||
for(typeof((array).tab) var = &(array).tab[__foreach_index_##var]; \
|
||||
(__foreach_index_##var > -1) && \
|
||||
(var = &(array).tab[__foreach_index_##var]); \
|
||||
--__foreach_index_##var)
|
||||
|
||||
/** Common array functions */
|
||||
#define ARRAY_COMMON_FUNCS(type_t, pfx, dtor) \
|
||||
static inline pfx##_array_t * pfx##_array_new(void) { \
|
||||
|
|
Loading…
Reference in New Issue