diff options
author | Nick Mathewson <nickm@torproject.org> | 2007-06-08 18:41:09 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2007-06-08 18:41:09 +0000 |
commit | 7a6f3cd223a34b76b7bc183f0465fcfdddc405b2 (patch) | |
tree | 8633623961b45fb2163d6c5a74ea7524929e4687 /src/or/routerparse.c | |
parent | e766814903c4ee7a03653853a1f35ac8f6a26589 (diff) | |
download | tor-7a6f3cd223a34b76b7bc183f0465fcfdddc405b2.tar tor-7a6f3cd223a34b76b7bc183f0465fcfdddc405b2.tar.gz |
r13313@catbus: nickm | 2007-06-08 14:23:11 -0400
Refactor v3 vote generation code into "build a networkstatus_vote_t" and "format a networkstatus_vote_t". This should make testing possible.
svn:r10533
Diffstat (limited to 'src/or/routerparse.c')
-rw-r--r-- | src/or/routerparse.c | 33 |
1 files changed, 8 insertions, 25 deletions
diff --git a/src/or/routerparse.c b/src/or/routerparse.c index be984d263..e5645787c 100644 --- a/src/or/routerparse.c +++ b/src/or/routerparse.c @@ -1287,22 +1287,6 @@ extrainfo_parse_entry_from_string(const char *s, const char *end, return extrainfo; } -/** Free storage held in <b>cert</b>. */ -void -authority_cert_free(authority_cert_t *cert) -{ - if (!cert) - return; - - tor_free(cert->cache_info.signed_descriptor_body); - if (cert->signing_key) - crypto_free_pk_env(cert->signing_key); - if (cert->identity_key) - crypto_free_pk_env(cert->identity_key); - - tor_free(cert); -} - /** Parse a key certificate from <b>s</b>; point <b>end-of-string</b> to * the first character after the certificate. */ authority_cert_t * @@ -1515,14 +1499,13 @@ routerstatus_parse_entry_from_string(const char **s, smartlist_t *tokens, tok = find_first_by_keyword(tokens, K_S); if (tok && vote) { - int i, j; + int i; vote_rs->flags = 0; for (i=0; i < tok->n_args; ++i) { - for (j=0; vote->known_flags[j]; ++j) { - if (!strcmp(tok->args[i], vote->known_flags[j])) { - vote_rs->flags |= (1<<j); - break; - } + int p = smartlist_string_pos(vote->known_flags, tok->args[i]); + if (p >= 0) { + vote_rs->flags |= (1<<p); + break; } } } else if (tok) { @@ -1869,9 +1852,9 @@ networkstatus_parse_vote_from_string(const char *s, int is_vote) } tok = find_first_by_keyword(tokens, K_KNOWN_FLAGS); - ns->known_flags = tor_malloc(sizeof(char*)*(tok->n_args+1)); - memcpy(ns->known_flags, tok->args, sizeof(char*)*(tok->n_args)); - ns->known_flags[tok->n_args] = NULL; + ns->known_flags = smartlist_create(); + for (i = 0; i < tok->n_args; ++i) + smartlist_add(ns->known_flags, tok->args[i]); tok->n_args = 0; /* suppress free of args members, but not of args itself. */ ns->voters = smartlist_create(); |