From: Caio Marcelo de Oliveira Filho Date: Wed, 12 Sep 2018 22:21:20 +0000 (-0700) Subject: util: Add macro to get number of elements in dynarray X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=b29ec31854ca110ffcf9e1fd30c4d6f8321d3059;p=mesa.git util: Add macro to get number of elements in dynarray Reviewed-by: Christian Gmeiner --- diff --git a/src/util/u_dynarray.h b/src/util/u_dynarray.h index 6bea481d44b..512c0efc762 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; \