mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-22 10:10:06 +00:00
Add ISC_LIST_FOREACH_REV(_SAFE) macros
Add complementary macros to ISC_LIST_FOREACH(_SAFE) that walk the lists in reverse. * ISC_LIST_FOREACH_REV(list, elt, link) - walk the static list from tail to head * ISC_LIST_FOREACH_REV_SAFE(list, elt, link, next) - walk the list from tail to head in a manner that's safe against list member deletions
This commit is contained in:
parent
fd732a7fb5
commit
d2e84a4b97
@ -78,4 +78,4 @@ PenaltyBreakString: 80
|
|||||||
PenaltyExcessCharacter: 100
|
PenaltyExcessCharacter: 100
|
||||||
Standard: Cpp11
|
Standard: Cpp11
|
||||||
ContinuationIndentWidth: 8
|
ContinuationIndentWidth: 8
|
||||||
ForEachMacros: [ 'cds_lfs_for_each', 'cds_lfs_for_each_safe', 'cds_list_for_each_entry_safe', 'ISC_LIST_FOREACH', 'ISC_LIST_FOREACH_SAFE' ]
|
ForEachMacros: [ 'cds_lfs_for_each', 'cds_lfs_for_each_safe', 'cds_list_for_each_entry_safe', 'ISC_LIST_FOREACH', 'ISC_LIST_FOREACH_SAFE', 'ISC_LIST_FOREACH_REV', 'ISC_LIST_FOREACH_REV_SAFE' ]
|
||||||
|
@ -241,3 +241,17 @@
|
|||||||
elt != NULL; \
|
elt != NULL; \
|
||||||
elt = next, next = (elt != NULL) ? ISC_LIST_NEXT(elt, link) : NULL)
|
elt = next, next = (elt != NULL) ? ISC_LIST_NEXT(elt, link) : NULL)
|
||||||
/* clang-format on */
|
/* clang-format on */
|
||||||
|
|
||||||
|
/* clang-format off */
|
||||||
|
#define ISC_LIST_FOREACH_REV(list, elt, link) \
|
||||||
|
for (elt = ISC_LIST_TAIL(list); \
|
||||||
|
elt != NULL; \
|
||||||
|
elt = ISC_LIST_PREV(elt, link))
|
||||||
|
/* clang-format on */
|
||||||
|
|
||||||
|
/* clang-format off */
|
||||||
|
#define ISC_LIST_FOREACH_REV_SAFE(list, elt, link, prev) \
|
||||||
|
for (elt = ISC_LIST_TAIL(list), prev = (elt != NULL) ? ISC_LIST_PREV(elt, link) : NULL; \
|
||||||
|
elt != NULL; \
|
||||||
|
elt = prev, prev = (elt != NULL) ? ISC_LIST_PREV(elt, link) : NULL)
|
||||||
|
/* clang-format on */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user