diff options
author | Nick Mathewson <nickm@torproject.org> | 2008-07-30 13:04:28 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2008-07-30 13:04:28 +0000 |
commit | f366d10a2ff46096b1c0a169ade125977cc33f1c (patch) | |
tree | 84028b7e6d51af302052724445264549cc83c354 /src | |
parent | e5bc5f11b87cee1a8f0630f6527bf5a7b1726d44 (diff) | |
download | tor-f366d10a2ff46096b1c0a169ade125977cc33f1c.tar.gz tor-f366d10a2ff46096b1c0a169ade125977cc33f1c.zip |
r17435@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.
svn:r16256
Diffstat (limited to 'src')
-rw-r--r-- | src/common/container.h | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/common/container.h b/src/common/container.h index 3746c30567..70a593887f 100644 --- a/src/common/container.h +++ b/src/common/container.h @@ -195,15 +195,21 @@ char *smartlist_join_strings2(smartlist_t *sl, const char *join, * } * </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 |