diff options
Diffstat (limited to 'src/or/dirauth')
-rw-r--r-- | src/or/dirauth/dirvote.c | 13 | ||||
-rw-r--r-- | src/or/dirauth/dirvote.h | 7 |
2 files changed, 20 insertions, 0 deletions
diff --git a/src/or/dirauth/dirvote.c b/src/or/dirauth/dirvote.c index 3ec4d67416..53a896eb4d 100644 --- a/src/or/dirauth/dirvote.c +++ b/src/or/dirauth/dirvote.c @@ -3899,3 +3899,16 @@ dirvote_parse_sr_commits(networkstatus_t *ns, smartlist_t *tokens) } } +/* For the given vote, free the shared random commits if any. */ +void +dirvote_clear_commits(networkstatus_t *ns) +{ + tor_assert(ns->type == NS_TYPE_VOTE); + + if (ns->sr_info.commits) { + SMARTLIST_FOREACH(ns->sr_info.commits, sr_commit_t *, c, + sr_commit_free(c)); + smartlist_free(ns->sr_info.commits); + } +} + diff --git a/src/or/dirauth/dirvote.h b/src/or/dirauth/dirvote.h index 4514c6daf0..9682c60364 100644 --- a/src/or/dirauth/dirvote.h +++ b/src/or/dirauth/dirvote.h @@ -100,6 +100,7 @@ void dirvote_act(const or_options_t *options, time_t now); void dirvote_free_all(void); void dirvote_parse_sr_commits(networkstatus_t *ns, smartlist_t *tokens); +void dirvote_clear_commits(networkstatus_t *ns); #else /* HAVE_MODULE_DIRAUTH */ @@ -122,6 +123,12 @@ dirvote_parse_sr_commits(networkstatus_t *ns, smartlist_t *tokens) (void) tokens; } +static inline void +dirvote_clear_commits(networkstatus_t *ns) +{ + (void) ns; +} + #endif /* HAVE_MODULE_DIRAUTH */ void dirvote_recalculate_timing(const or_options_t *options, time_t now); |