summaryrefslogtreecommitdiff
path: root/testing/misc_tools.h
diff options
context:
space:
mode:
authorAnony Moose <noMail@nomail.su>2013-08-24 21:45:45 +0000
committerAnony Moose <noMail@nomail.su>2013-08-24 21:45:45 +0000
commit9a7f7b5ec4033b83bbde8a7347895994e7aad6c4 (patch)
tree2ad92d7c3d3c73a3cc155386dafb1e0225d7b715 /testing/misc_tools.h
parentae3ab2efa46f25ab33ce08fe60c105cb6d4e3e31 (diff)
Added array for loop.
Diffstat (limited to 'testing/misc_tools.h')
-rw-r--r--testing/misc_tools.h14
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