diff options
author | Nick Mathewson <nickm@torproject.org> | 2007-02-24 07:37:45 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2007-02-24 07:37:45 +0000 |
commit | f599adf40ad702f26680ab6a7bbf869c788dd860 (patch) | |
tree | 8ede61d62d801797f6e39e276560cc3d30cb4182 /src/common | |
parent | 2015479b5a8f58d78e379c434cda82e7c4a86b95 (diff) | |
download | tor-f599adf40ad702f26680ab6a7bbf869c788dd860.tar.gz tor-f599adf40ad702f26680ab6a7bbf869c788dd860.zip |
r11909@catbus: nickm | 2007-02-24 02:37:40 -0500
Move tricky "delete the member of the smartlist currently under iteration" logic into its own happyfun macro.
svn:r9633
Diffstat (limited to 'src/common')
-rw-r--r-- | src/common/container.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/common/container.h b/src/common/container.h index ff2d3cb011..fbd3c6c603 100644 --- a/src/common/container.h +++ b/src/common/container.h @@ -156,6 +156,16 @@ char *smartlist_join_strings2(smartlist_t *sl, const char *join, cmd; \ } } while (0) +/** Helper: While in a SMARTLIST_FOREACH loop over the list <b>sl</b> indexed + * with the variable <b>var</b>, remover the current element in a way that + * won't confuse the loop. */ +#define SMARTLIST_DEL_CURRENT(sl, var) \ + do { \ + smartlist_del(sl, var ## _sl_idx); \ + --var ## _sl_idx; \ + --var ## _sl_len; \ + } while (0); + #define DECLARE_MAP_FNS(maptype, keytype, prefix) \ typedef struct maptype maptype; \ typedef struct prefix##entry_t *prefix##iter_t; \ |