diff options
author | Nick Mathewson <nickm@torproject.org> | 2014-05-01 12:29:31 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2014-05-01 12:29:31 -0400 |
commit | b51ce907771d3fbeeb2dcba3c109d3ee25850f4c (patch) | |
tree | f968f0ab32c5b6c64dcd4f9c8695e6a1a32ae59d /src/or | |
parent | b6c8a14bf35c4572fba49be9eb4aaaa78d776c4c (diff) | |
parent | 3866792cd04d95c80eb5dd1e7cb2fddf0c05f9b8 (diff) | |
download | tor-b51ce907771d3fbeeb2dcba3c109d3ee25850f4c.tar.gz tor-b51ce907771d3fbeeb2dcba3c109d3ee25850f4c.zip |
Merge remote-tracking branch 'public/valgrind_tests'
Diffstat (limited to 'src/or')
-rw-r--r-- | src/or/networkstatus.c | 3 | ||||
-rw-r--r-- | src/or/networkstatus.h | 4 | ||||
-rw-r--r-- | src/or/statefile.c | 29 | ||||
-rw-r--r-- | src/or/statefile.h | 2 |
4 files changed, 30 insertions, 8 deletions
diff --git a/src/or/networkstatus.c b/src/or/networkstatus.c index ef450073e7..90918d4fef 100644 --- a/src/or/networkstatus.c +++ b/src/or/networkstatus.c @@ -10,6 +10,7 @@ * client or cache. */ +#define NETWORKSTATUS_PRIVATE #include "or.h" #include "channel.h" #include "circuitmux.h" @@ -183,7 +184,7 @@ router_reload_consensus_networkstatus(void) } /** Free all storage held by the vote_routerstatus object <b>rs</b>. */ -static void +STATIC void vote_routerstatus_free(vote_routerstatus_t *rs) { vote_microdesc_hash_t *h, *next; diff --git a/src/or/networkstatus.h b/src/or/networkstatus.h index 1659818f0a..be0a86cdd8 100644 --- a/src/or/networkstatus.h +++ b/src/or/networkstatus.h @@ -99,5 +99,9 @@ document_signature_t *document_signature_dup(const document_signature_t *sig); void networkstatus_free_all(void); int networkstatus_get_weight_scale_param(networkstatus_t *ns); +#ifdef NETWORKSTATUS_PRIVATE +STATIC void vote_routerstatus_free(vote_routerstatus_t *rs); +#endif + #endif diff --git a/src/or/statefile.c b/src/or/statefile.c index da31341712..a50eae5ff4 100644 --- a/src/or/statefile.c +++ b/src/or/statefile.c @@ -294,6 +294,16 @@ or_state_save_broken(char *fname) tor_free(fname2); } +STATIC or_state_t * +or_state_new(void) +{ + or_state_t *new_state = tor_malloc_zero(sizeof(or_state_t)); + new_state->magic_ = OR_STATE_MAGIC; + config_init(&state_format, new_state); + + return new_state; +} + /** Reload the persistent state from disk, generating a new state as needed. * Return 0 on success, less than 0 on failure. */ @@ -321,9 +331,7 @@ or_state_load(void) log_warn(LD_GENERAL,"State file \"%s\" is not a file? Failing.", fname); goto done; } - new_state = tor_malloc_zero(sizeof(or_state_t)); - new_state->magic_ = OR_STATE_MAGIC; - config_init(&state_format, new_state); + new_state = or_state_new(); if (contents) { config_line_t *lines=NULL; int assign_retval; @@ -358,9 +366,7 @@ or_state_load(void) tor_free(contents); config_free(&state_format, new_state); - new_state = tor_malloc_zero(sizeof(or_state_t)); - new_state->magic_ = OR_STATE_MAGIC; - config_init(&state_format, new_state); + new_state = or_state_new(); } else if (contents) { log_info(LD_GENERAL, "Loaded state from \"%s\"", fname); } else { @@ -625,10 +631,19 @@ save_transport_to_state(const char *transport, tor_free(transport_addrport); } +STATIC void +or_state_free(or_state_t *state) +{ + if (!state) + return; + + config_free(&state_format, state); +} + void or_state_free_all(void) { - config_free(&state_format, global_state); + or_state_free(global_state); global_state = NULL; } diff --git a/src/or/statefile.h b/src/or/statefile.h index c1413ff952..15bb0b4aae 100644 --- a/src/or/statefile.h +++ b/src/or/statefile.h @@ -20,6 +20,8 @@ void or_state_free_all(void); #ifdef STATEFILE_PRIVATE STATIC config_line_t *get_transport_in_state_by_name(const char *transport); +STATIC void or_state_free(or_state_t *state); +STATIC or_state_t *or_state_new(void); #endif #endif |