[Mesa-dev] [PATCH 02/11] util: Add macro to get number of elements in dynarray
Caio Marcelo de Oliveira Filho
caio.oliveira at intel.com
Sat Sep 15 05:45:24 UTC 2018
---
I've ended up not using this macro in this series, but it is useful
for other cases, so kept it here.
src/util/u_dynarray.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/util/u_dynarray.h b/src/util/u_dynarray.h
index f74bfc7080b..53dde9241bb 100644
--- a/src/util/u_dynarray.h
+++ b/src/util/u_dynarray.h
@@ -149,6 +149,7 @@ util_dynarray_trim(struct util_dynarray *buf)
#define util_dynarray_element(buf, type, idx) ((type*)(buf)->data + (idx))
#define util_dynarray_begin(buf) ((buf)->data)
#define util_dynarray_end(buf) ((void*)util_dynarray_element((buf), char, (buf)->size))
+#define util_dynarray_num_elements(buf, type) ((buf)->size / sizeof(type))
#define util_dynarray_foreach(buf, type, elem) \
for (type *elem = (type *)(buf)->data; \
--
2.19.0
More information about the mesa-dev
mailing list