From b29ec31854ca110ffcf9e1fd30c4d6f8321d3059 Mon Sep 17 00:00:00 2001 From: Caio Marcelo de Oliveira Filho Date: Wed, 12 Sep 2018 15:21:20 -0700 Subject: [PATCH] util: Add macro to get number of elements in dynarray Reviewed-by: Christian Gmeiner --- 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 6bea481..512c0ef 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.7.4