diff options
Diffstat (limited to 'testing/misc_tools.h')
-rw-r--r-- | testing/misc_tools.h | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/testing/misc_tools.h b/testing/misc_tools.h index 0ffd51e7..7c37ba38 100644 --- a/testing/misc_tools.h +++ b/testing/misc_tools.h | |||
@@ -153,6 +153,16 @@ static inline void tox_array_pop(tox_array *arr, uint32_t num) | |||
153 | arr->data = realloc(arr->data, arr->elem_size*arr->len); | 153 | arr->data = realloc(arr->data, arr->elem_size*arr->len); |
154 | } | 154 | } |
155 | 155 | ||
156 | #define tox_array_get(arr, i, type) ((type*)(arr)->data)[i] | 156 | #define tox_array_get(arr, i, type) (((type*)(arr)->data)[i]) |
157 | 157 | ||
158 | #endif // MISC_TOOLS_H | 158 | /* TODO: what about nested for loops? */ |
159 | #define tox_array_for_each(arr, type) \ | ||
160 | for ( \ | ||
161 | struct { type tmp; uint32_t i; } tox_array_tmp = { tox_array_get(arr, 0, type), 0 }; \ | ||
162 | tox_array_tmp.i != (arr)->len; \ | ||
163 | tox_array_tmp.tmp = tox_array_get(arr, ++tox_array_tmp.i, type) \ | ||
164 | ) | ||
165 | |||
166 | #define TOX_ARRAY_TMP (tox_array_tmp.tmp) | ||
167 | |||
168 | #endif // MISC_TOOLS_H \ No newline at end of file | ||