[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [tor/master] Provide a smartlist reverse-order traversal.



commit 3ba7581129dcffb16cca2aa8cfc2bd0fa4c8dd06
Author: Mike Perry <mikeperry-git@xxxxxxxxxxxxxx>
Date:   Tue Oct 23 19:23:09 2018 +0000

    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@xxxxxxxxxx>
---
 src/lib/smartlist_core/smartlist_foreach.h | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/src/lib/smartlist_core/smartlist_foreach.h b/src/lib/smartlist_core/smartlist_foreach.h
index 54f08ac47..14f2930c9 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;                      \



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits