summaryrefslogtreecommitdiffstats
path: root/src/util/u_dynarray.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/util/u_dynarray.h')
-rw-r--r--src/util/u_dynarray.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/util/u_dynarray.h b/src/util/u_dynarray.h
index 512c0efc762..c1aa79c8ac6 100644
--- a/src/util/u_dynarray.h
+++ b/src/util/u_dynarray.h
@@ -155,6 +155,12 @@ util_dynarray_trim(struct util_dynarray *buf)
for (type *elem = (type *)(buf)->data; \
elem < (type *)((char *)(buf)->data + (buf)->size); elem++)
+#define util_dynarray_foreach_reverse(buf, type, elem) \
+ if ((buf)->size > 0) \
+ for (type *elem = util_dynarray_top_ptr(buf, type); \
+ elem; \
+ elem = elem > (type *)(buf)->data ? elem - 1 : NULL)
+
#define util_dynarray_delete_unordered(buf, type, v) \
do { \
unsigned num_elements = (buf)->size / sizeof(type); \