[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [tor/master] Added a voting_schedule_free function to free voting schedules.
commit 8c0fdf6a276077123c356f3fc9d29eebfc41db72
Author: Daniel Pinto <danielpinto52@xxxxxxxxx>
Date: Tue Aug 16 17:53:38 2016 +0100
Added a voting_schedule_free function to free voting schedules.
Existing Uses of the tor_free function on voting schedules were
replaced with voting_schedule_free.
Fixes #19562.
---
src/or/dirvote.c | 11 +++++++++--
src/or/dirvote.h | 2 ++
src/or/shared_random.c | 2 +-
src/or/shared_random_state.c | 2 +-
4 files changed, 13 insertions(+), 4 deletions(-)
diff --git a/src/or/dirvote.c b/src/or/dirvote.c
index 94a13e3..7c80868 100644
--- a/src/or/dirvote.c
+++ b/src/or/dirvote.c
@@ -2577,7 +2577,7 @@ get_next_valid_after_time(time_t now)
tor_assert(new_voting_schedule);
next_valid_after_time = new_voting_schedule->interval_starts;
- tor_free(new_voting_schedule);
+ free_voting_schedule(new_voting_schedule);
return next_valid_after_time;
}
@@ -2601,7 +2601,7 @@ dirvote_recalculate_timing(const or_options_t *options, time_t now)
/* Fill in the global static struct now */
memcpy(&voting_schedule, new_voting_schedule, sizeof(voting_schedule));
- tor_free(new_voting_schedule);
+ free_voting_schedule(new_voting_schedule);
}
/* Populate and return a new voting_schedule_t that can be used to schedule
@@ -2660,6 +2660,13 @@ get_voting_schedule(const or_options_t *options, time_t now, int severity)
return new_voting_schedule;
}
+/** Frees a voting_schedule_t. This should be used instead of the generic tor_free. */
+void
+free_voting_schedule(voting_schedule_t *voting_schedule_to_free)
+{
+ tor_free(voting_schedule_to_free);
+}
+
/** Entry point: Take whatever voting actions are pending as of <b>now</b>. */
void
dirvote_act(const or_options_t *options, time_t now)
diff --git a/src/or/dirvote.h b/src/or/dirvote.h
index 2a83802..23084cd 100644
--- a/src/or/dirvote.h
+++ b/src/or/dirvote.h
@@ -157,6 +157,8 @@ typedef struct {
voting_schedule_t *get_voting_schedule(const or_options_t *options,
time_t now, int severity);
+void free_voting_schedule(voting_schedule_t *voting_schedule_to_free);
+
void dirvote_get_preferred_voting_intervals(vote_timing_t *timing_out);
time_t dirvote_get_start_of_next_interval(time_t now,
int interval,
diff --git a/src/or/shared_random.c b/src/or/shared_random.c
index 0a1f24a..4453052 100644
--- a/src/or/shared_random.c
+++ b/src/or/shared_random.c
@@ -1328,7 +1328,7 @@ sr_act_post_consensus(const networkstatus_t *consensus)
get_voting_schedule(options,time(NULL), LOG_NOTICE);
time_t interval_starts = voting_schedule->interval_starts;
sr_state_update(interval_starts);
- tor_free(voting_schedule);
+ free_voting_schedule(voting_schedule);
}
}
diff --git a/src/or/shared_random_state.c b/src/or/shared_random_state.c
index 52a0034..4985af1 100644
--- a/src/or/shared_random_state.c
+++ b/src/or/shared_random_state.c
@@ -150,7 +150,7 @@ get_start_time_of_current_round(time_t now)
voting_interval,
options->TestingV3AuthVotingStartOffset);
- tor_free(new_voting_schedule);
+ free_voting_schedule(new_voting_schedule);
return curr_start;
}
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits