diff options
author | Nick Mathewson <nickm@torproject.org> | 2019-07-23 10:13:29 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2019-07-24 15:21:56 -0400 |
commit | 57e87cc86cce0b9fb351b1862f99c84bfa8100eb (patch) | |
tree | 38b5ba153f209fe127ad61a95cf30c9adf4443fa /src/feature/dirauth/shared_random_state.c | |
parent | a1b2817abefc5c696e469fa4fd8a09cc5f286aa6 (diff) | |
download | tor-57e87cc86cce0b9fb351b1862f99c84bfa8100eb.tar.gz tor-57e87cc86cce0b9fb351b1862f99c84bfa8100eb.zip |
Use config_new() to construct configuration objects.
We'll need to do it this way once the objects become more complex.
Diffstat (limited to 'src/feature/dirauth/shared_random_state.c')
-rw-r--r-- | src/feature/dirauth/shared_random_state.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/feature/dirauth/shared_random_state.c b/src/feature/dirauth/shared_random_state.c index 12ae79ce37..21bf3c1226 100644 --- a/src/feature/dirauth/shared_random_state.c +++ b/src/feature/dirauth/shared_random_state.c @@ -285,9 +285,8 @@ disk_state_free_(sr_disk_state_t *state) static sr_disk_state_t * disk_state_new(time_t now) { - sr_disk_state_t *new_state = tor_malloc_zero(sizeof(*new_state)); + sr_disk_state_t *new_state = config_new(get_srs_mgr()); - new_state->magic_ = SR_DISK_STATE_MAGIC; new_state->Version = SR_PROTO_VERSION; new_state->TorVersion = tor_strdup(get_version()); new_state->ValidUntil = get_state_valid_until_time(now); @@ -599,11 +598,12 @@ disk_state_reset(void) config_free_lines(sr_disk_state->ExtraLines); tor_free(sr_disk_state->TorVersion); - /* Clean up the struct */ - memset(sr_disk_state, 0, sizeof(*sr_disk_state)); + /* Clear other fields. */ + sr_disk_state->ValidAfter = 0; + sr_disk_state->ValidUntil = 0; + sr_disk_state->Version = 0; /* Reset it with useful data */ - sr_disk_state->magic_ = SR_DISK_STATE_MAGIC; sr_disk_state->TorVersion = tor_strdup(get_version()); } |