diff options
author | Mike Perry <mikeperry-git@torproject.org> | 2018-10-23 19:23:09 +0000 |
---|---|---|
committer | George Kadianakis <desnacked@riseup.net> | 2019-01-02 15:09:13 +0200 |
commit | 3ba7581129dcffb16cca2aa8cfc2bd0fa4c8dd06 (patch) | |
tree | 3fb868f43adb2e25750aabb6834e1d22f0bd9938 /src | |
parent | 99713b176b3713c3960be7b2852ffdb301daa916 (diff) | |
download | tor-3ba7581129dcffb16cca2aa8cfc2bd0fa4c8dd06.tar.gz tor-3ba7581129dcffb16cca2aa8cfc2bd0fa4c8dd06.zip |
Provide a smartlist reverse-order traversal.
We need this for padding negotiation so that we can have later machine
revisions supercede earlier ones.
Co-authored-by: George Kadianakis <desnacked@riseup.net>
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/smartlist_core/smartlist_foreach.h | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/lib/smartlist_core/smartlist_foreach.h b/src/lib/smartlist_core/smartlist_foreach.h index 54f08ac47d..14f2930c9f 100644 --- a/src/lib/smartlist_core/smartlist_foreach.h +++ b/src/lib/smartlist_core/smartlist_foreach.h @@ -83,6 +83,14 @@ ++var ## _sl_idx) { \ var = (sl)->list[var ## _sl_idx]; +#define SMARTLIST_FOREACH_REVERSE_BEGIN(sl, type, var) \ + STMT_BEGIN \ + int var ## _sl_idx, var ## _sl_len=(sl)->num_used; \ + type var; \ + for (var ## _sl_idx = var ## _sl_len-1; var ## _sl_idx >= 0; \ + --var ## _sl_idx) { \ + var = (sl)->list[var ## _sl_idx]; + #define SMARTLIST_FOREACH_END(var) \ var = NULL; \ (void) var ## _sl_idx; \ |