From 29c9549f6bbd4a2bf841342fc49e8e32d2cb4e14 Mon Sep 17 00:00:00 2001 From: fengzero Date: Fri, 27 May 2022 09:01:57 +0000 Subject: [PATCH] utarray reverse foreach --- include/neuron/utils/utextend.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/neuron/utils/utextend.h b/include/neuron/utils/utextend.h index 7373d66e..f4d85a5e 100644 --- a/include/neuron/utils/utextend.h +++ b/include/neuron/utils/utextend.h @@ -43,6 +43,10 @@ static inline UT_array *utarray_clone(UT_array *array) for (type elem = (type) utarray_front(array); elem != NULL; \ elem = (type) utarray_next(array, elem)) +#define utarray_reverse_foreach(array, type, elem) \ + for (type elem = (type) utarray_back(array); elem != NULL; \ + elem = (type) utarray_prev(array, elem)) + #define DL_LAST(head) ((head) != NULL) ? (head)->prev : NULL; #define DL_PREV(el) ((el) != NULL) ? (el)->prev : NULL;