[or-cvs] r16256: Allow alternate form of SMARTLIST_FOREACH with paired BEGIN (in tor/trunk: . src/common)

nickm at seul.org nickm at seul.org
Wed Jul 30 13:04:29 UTC 2008


Author: nickm
Date: 2008-07-30 09:04:28 -0400 (Wed, 30 Jul 2008)
New Revision: 16256

Modified:
   tor/trunk/
   tor/trunk/src/common/container.h
Log:
 r17435 at tombo:  nickm | 2008-07-30 08:50:54 -0400
 Allow alternate form of SMARTLIST_FOREACH with paired BEGIN and END macros.  This lets the compiler tell us which line an error has occurred on.



Property changes on: tor/trunk
___________________________________________________________________
 svk:merge ticket from /tor/trunk [r17435] on 49666b30-7950-49c5-bedf-9dc8f3168102

Modified: tor/trunk/src/common/container.h
===================================================================
--- tor/trunk/src/common/container.h	2008-07-30 13:04:26 UTC (rev 16255)
+++ tor/trunk/src/common/container.h	2008-07-30 13:04:28 UTC (rev 16256)
@@ -195,16 +195,22 @@
  * }
  * </pre>
  */
-#define SMARTLIST_FOREACH(sl, type, var, cmd)                   \
+#define SMARTLIST_FOREACH_BEGIN(sl, type, var)  \
   STMT_BEGIN                                                    \
     int var ## _sl_idx, var ## _sl_len=(sl)->num_used;          \
     type var;                                                   \
     for (var ## _sl_idx = 0; var ## _sl_idx < var ## _sl_len;   \
          ++var ## _sl_idx) {                                    \
-      var = (sl)->list[var ## _sl_idx];                         \
-      cmd;                                                      \
-    } STMT_END
+      var = (sl)->list[var ## _sl_idx];
 
+#define SMARTLIST_FOREACH_END(var)              \
+  } STMT_END
+
+#define SMARTLIST_FOREACH(sl, type, var, cmd)                   \
+  SMARTLIST_FOREACH_BEGIN(sl,type,var) {                        \
+    cmd;                                                        \
+  } SMARTLIST_FOREACH_END(var)
+
 /** Helper: While in a SMARTLIST_FOREACH loop over the list <b>sl</b> indexed
  * with the variable <b>var</b>, remove the current element in a way that
  * won't confuse the loop. */



More information about the tor-commits mailing list