[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [tor/master] Change the free macro convention in the rest of src/or/*.h



commit 176ad729d9b1ddeccdb3e721b5ab1bf64646223f
Author: Nick Mathewson <nickm@xxxxxxxxxxxxxx>
Date:   Tue Nov 21 09:37:47 2017 -0500

    Change the free macro convention in the rest of src/or/*.h
---
 src/or/connection_or.c    |  4 ++--
 src/or/connection_or.h    |  7 +++++--
 src/or/conscache.c        |  2 +-
 src/or/conscache.h        |  3 ++-
 src/or/dircollate.c       |  2 +-
 src/or/dircollate.h       |  3 ++-
 src/or/directory.c        |  2 +-
 src/or/directory.h        |  3 ++-
 src/or/dirserv.c          |  2 +-
 src/or/dirserv.h          |  3 ++-
 src/or/dirvote.c          |  2 +-
 src/or/dirvote.h          |  4 +++-
 src/or/entrynodes.c       |  4 ++--
 src/or/entrynodes.h       |  7 +++++--
 src/or/fp_pair.c          |  2 +-
 src/or/fp_pair.h          |  7 ++++++-
 src/or/hs_common.c        |  2 +-
 src/or/hs_common.h        |  3 ++-
 src/or/hs_descriptor.c    | 10 +++++-----
 src/or/hs_descriptor.h    | 19 ++++++++++++++-----
 src/or/hs_ident.c         |  6 +++---
 src/or/hs_ident.h         |  9 ++++++---
 src/or/hs_service.c       | 10 +++++-----
 src/or/hs_service.h       | 20 +++++++++++---------
 src/or/microdesc.h        |  6 ++++--
 src/or/networkstatus.c    |  8 ++++----
 src/or/networkstatus.h    | 12 ++++++++----
 src/or/onion.c            |  2 +-
 src/or/onion.h            |  3 ++-
 src/or/onion_fast.c       |  2 +-
 src/or/onion_fast.h       |  4 +++-
 src/or/onion_ntor.c       |  2 +-
 src/or/onion_ntor.h       |  4 +++-
 src/or/policies.c         |  6 +++---
 src/or/policies.h         |  9 ++++++---
 src/or/proto_socks.c      |  2 +-
 src/or/proto_socks.h      |  3 ++-
 src/or/protover.c         |  2 +-
 src/or/protover.h         |  4 ++--
 src/or/relay.c            |  4 ++--
 src/or/relay.h            |  6 ++++--
 src/or/rendcache.c        | 26 +++++++++++++-------------
 src/or/rendcache.h        | 15 ++++++++++-----
 src/or/rendcommon.c       |  6 +++---
 src/or/rendcommon.h       | 11 ++++++++---
 src/or/rendservice.c      |  8 ++++----
 src/or/rendservice.h      | 17 +++++++++++++----
 src/or/replaycache.c      |  2 +-
 src/or/replaycache.h      |  3 ++-
 src/or/router.c           |  2 +-
 src/or/router.h           |  3 ++-
 src/or/routerlist.c       | 16 ++++++++--------
 src/or/routerlist.h       | 12 ++++++++----
 src/or/routerset.c        |  2 +-
 src/or/routerset.h        |  3 ++-
 src/or/shared_random.c    |  2 +-
 src/or/shared_random.h    |  3 ++-
 src/or/statefile.c        |  2 +-
 src/or/statefile.h        |  3 ++-
 src/or/torcert.c          |  4 ++--
 src/or/torcert.h          |  7 +++++--
 src/or/transports.c       |  2 +-
 src/or/transports.h       |  3 ++-
 src/test/test_rendcache.c |  8 ++++----
 src/test/test_replay.c    |  2 +-
 src/test/test_routerset.c | 10 +++++-----
 66 files changed, 234 insertions(+), 153 deletions(-)

diff --git a/src/or/connection_or.c b/src/or/connection_or.c
index fa8991596..541d78e6e 100644
--- a/src/or/connection_or.c
+++ b/src/or/connection_or.c
@@ -505,7 +505,7 @@ var_cell_copy(const var_cell_t *src)
 
 /** Release all space held by <b>cell</b>. */
 void
-var_cell_free(var_cell_t *cell)
+var_cell_free_(var_cell_t *cell)
 {
   tor_free(cell);
 }
@@ -1854,7 +1854,7 @@ connection_init_or_handshake_state(or_connection_t *conn, int started_here)
 
 /** Free all storage held by <b>state</b>. */
 void
-or_handshake_state_free(or_handshake_state_t *state)
+or_handshake_state_free_(or_handshake_state_t *state)
 {
   if (!state)
     return;
diff --git a/src/or/connection_or.h b/src/or/connection_or.h
index ee66b7c52..107af491e 100644
--- a/src/or/connection_or.h
+++ b/src/or/connection_or.h
@@ -68,7 +68,9 @@ int connection_or_client_learned_peer_id(or_connection_t *conn,
                               const ed25519_public_key_t *ed_peer_id);
 time_t connection_or_client_used(or_connection_t *conn);
 MOCK_DECL(int, connection_or_get_num_circuits, (or_connection_t *conn));
-void or_handshake_state_free(or_handshake_state_t *state);
+void or_handshake_state_free_(or_handshake_state_t *state);
+#define or_handshake_state_free(state) \
+  FREE_AND_NULL(or_handshake_state, (state))
 void or_handshake_state_record_cell(or_connection_t *conn,
                                     or_handshake_state_t *state,
                                     const cell_t *cell,
@@ -105,7 +107,8 @@ int var_cell_pack_header(const var_cell_t *cell, char *hdr_out,
                          int wide_circ_ids);
 var_cell_t *var_cell_new(uint16_t payload_len);
 var_cell_t *var_cell_copy(const var_cell_t *src);
-void var_cell_free(var_cell_t *cell);
+void var_cell_free_(var_cell_t *cell);
+#define var_cell_free(cell) FREE_AND_NULL(var_cell, (cell))
 
 /* DOCDOC */
 #define MIN_LINK_PROTO_FOR_WIDE_CIRC_IDS 4
diff --git a/src/or/conscache.c b/src/or/conscache.c
index 0f3e453ea..3330dbce2 100644
--- a/src/or/conscache.c
+++ b/src/or/conscache.c
@@ -170,7 +170,7 @@ consensus_cache_clear(consensus_cache_t *cache)
  * Drop all storage held by <b>cache</b>.
  */
 void
-consensus_cache_free(consensus_cache_t *cache)
+consensus_cache_free_(consensus_cache_t *cache)
 {
   if (! cache)
     return;
diff --git a/src/or/conscache.h b/src/or/conscache.h
index e4f308fa4..0c02f6ebc 100644
--- a/src/or/conscache.h
+++ b/src/or/conscache.h
@@ -14,7 +14,8 @@ HANDLE_DECL(consensus_cache_entry, consensus_cache_entry_t, )
   FREE_AND_NULL(consensus_cache_entry_handle, (h))
 
 consensus_cache_t *consensus_cache_open(const char *subdir, int max_entries);
-void consensus_cache_free(consensus_cache_t *cache);
+void consensus_cache_free_(consensus_cache_t *cache);
+#define consensus_cache_free(cache) FREE_AND_NULL(consensus_cache, (cache))
 struct sandbox_cfg_elem;
 int consensus_cache_may_overallocate(consensus_cache_t *cache);
 int consensus_cache_register_with_sandbox(consensus_cache_t *cache,
diff --git a/src/or/dircollate.c b/src/or/dircollate.c
index d34ebe8af..64226724b 100644
--- a/src/or/dircollate.c
+++ b/src/or/dircollate.c
@@ -158,7 +158,7 @@ dircollator_new(int n_votes, int n_authorities)
 
 /** Release all storage held by <b>dc</b>. */
 void
-dircollator_free(dircollator_t *dc)
+dircollator_free_(dircollator_t *dc)
 {
   if (!dc)
     return;
diff --git a/src/or/dircollate.h b/src/or/dircollate.h
index 7932e1899..ab44c83b0 100644
--- a/src/or/dircollate.h
+++ b/src/or/dircollate.h
@@ -18,7 +18,8 @@
 typedef struct dircollator_s dircollator_t;
 
 dircollator_t *dircollator_new(int n_votes, int n_authorities);
-void dircollator_free(dircollator_t *obj);
+void dircollator_free_(dircollator_t *obj);
+#define dircollator_free(c) FREE_AND_NULL(dircollator, (c))
 void dircollator_add_vote(dircollator_t *dc, networkstatus_t *v);
 
 void dircollator_collate(dircollator_t *dc, int consensus_method);
diff --git a/src/or/directory.c b/src/or/directory.c
index 0c40b2018..cb4e9c542 100644
--- a/src/or/directory.c
+++ b/src/or/directory.c
@@ -1101,7 +1101,7 @@ directory_request_new(uint8_t dir_purpose)
  * Release all resources held by <b>req</b>.
  */
 void
-directory_request_free(directory_request_t *req)
+directory_request_free_(directory_request_t *req)
 {
   if (req == NULL)
     return;
diff --git a/src/or/directory.h b/src/or/directory.h
index 3aef60071..89913038e 100644
--- a/src/or/directory.h
+++ b/src/or/directory.h
@@ -51,7 +51,8 @@ int directory_must_use_begindir(const or_options_t *options);
  */
 typedef struct directory_request_t directory_request_t;
 directory_request_t *directory_request_new(uint8_t dir_purpose);
-void directory_request_free(directory_request_t *req);
+void directory_request_free_(directory_request_t *req);
+#define directory_request_free(req) FREE_AND_NULL(directory_request, (req))
 void directory_request_set_or_addr_port(directory_request_t *req,
                                         const tor_addr_port_t *p);
 void directory_request_set_dir_addr_port(directory_request_t *req,
diff --git a/src/or/dirserv.c b/src/or/dirserv.c
index 432fe6ae2..91c8c1de5 100644
--- a/src/or/dirserv.c
+++ b/src/or/dirserv.c
@@ -3502,7 +3502,7 @@ spooled_resource_new_from_cache_entry(consensus_cache_entry_t *entry)
 
 /** Release all storage held by <b>spooled</b>. */
 void
-spooled_resource_free(spooled_resource_t *spooled)
+spooled_resource_free_(spooled_resource_t *spooled)
 {
   if (spooled == NULL)
     return;
diff --git a/src/or/dirserv.h b/src/or/dirserv.h
index 46967a6cb..037294bdb 100644
--- a/src/or/dirserv.h
+++ b/src/or/dirserv.h
@@ -195,7 +195,8 @@ spooled_resource_t *spooled_resource_new(dir_spool_source_t source,
                                          size_t digestlen);
 spooled_resource_t *spooled_resource_new_from_cache_entry(
                                       struct consensus_cache_entry_t *entry);
-void spooled_resource_free(spooled_resource_t *spooled);
+void spooled_resource_free_(spooled_resource_t *spooled);
+#define spooled_resource_free(sp) FREE_AND_NULL(spooled_resource, (sp))
 void dirserv_spool_remove_missing_and_guess_size(dir_connection_t *conn,
                                                  time_t cutoff,
                                                  int compression,
diff --git a/src/or/dirvote.c b/src/or/dirvote.c
index ce82a5ef4..0f8dff626 100644
--- a/src/or/dirvote.c
+++ b/src/or/dirvote.c
@@ -2685,7 +2685,7 @@ get_detached_signatures_from_pending_consensuses(pending_consensus_t *pending,
 
 /** Release all storage held in <b>s</b>. */
 void
-ns_detached_signatures_free(ns_detached_signatures_t *s)
+ns_detached_signatures_free_(ns_detached_signatures_t *s)
 {
   if (!s)
     return;
diff --git a/src/or/dirvote.h b/src/or/dirvote.h
index 72a35fea6..29fb07273 100644
--- a/src/or/dirvote.h
+++ b/src/or/dirvote.h
@@ -136,7 +136,9 @@ int networkstatus_add_detached_signatures(networkstatus_t *target,
                                           int severity,
                                           const char **msg_out);
 char *networkstatus_get_detached_signatures(smartlist_t *consensuses);
-void ns_detached_signatures_free(ns_detached_signatures_t *s);
+void ns_detached_signatures_free_(ns_detached_signatures_t *s);
+#define ns_detached_signatures_free(s) \
+  FREE_AND_NULL(ns_detached_signatures, (s))
 
 /* cert manipulation */
 authority_cert_t *authority_cert_dup(authority_cert_t *cert);
diff --git a/src/or/entrynodes.c b/src/or/entrynodes.c
index 38b9c2c56..244a01b5d 100644
--- a/src/or/entrynodes.c
+++ b/src/or/entrynodes.c
@@ -2197,7 +2197,7 @@ entry_guard_has_higher_priority(entry_guard_t *a, entry_guard_t *b)
 
 /** Release all storage held in <b>restriction</b> */
 STATIC void
-entry_guard_restriction_free(entry_guard_restriction_t *rst)
+entry_guard_restriction_free_(entry_guard_restriction_t *rst)
 {
   tor_free(rst);
 }
@@ -3602,7 +3602,7 @@ entry_guards_get_err_str_if_dir_info_missing(int using_mds,
 
 /** Free one guard selection context */
 STATIC void
-guard_selection_free(guard_selection_t *gs)
+guard_selection_free_(guard_selection_t *gs)
 {
   if (!gs) return;
 
diff --git a/src/or/entrynodes.h b/src/or/entrynodes.h
index d7f4967a0..5fd4c970d 100644
--- a/src/or/entrynodes.h
+++ b/src/or/entrynodes.h
@@ -486,7 +486,8 @@ STATIC guard_selection_t *guard_selection_new(const char *name,
                                               guard_selection_type_t type);
 STATIC guard_selection_t *get_guard_selection_by_name(
           const char *name, guard_selection_type_t type, int create_if_absent);
-STATIC void guard_selection_free(guard_selection_t *gs);
+STATIC void guard_selection_free_(guard_selection_t *gs);
+#define guard_selection_free(gs) FREE_AND_NULL(guard_selection, (gs))
 MOCK_DECL(STATIC int, entry_guard_is_listed,
           (guard_selection_t *gs, const entry_guard_t *guard));
 STATIC const char *choose_guard_selection(const or_options_t *options,
@@ -570,7 +571,9 @@ STATIC entry_guard_restriction_t *guard_create_exit_restriction(
 
 STATIC entry_guard_restriction_t *guard_create_dirserver_md_restriction(void);
 
-STATIC void entry_guard_restriction_free(entry_guard_restriction_t *rst);
+STATIC void entry_guard_restriction_free_(entry_guard_restriction_t *rst);
+#define entry_guard_restriction_free(rst) \
+  FREE_AND_NULL(entry_guard_restriction, (rst))
 
 #endif /* defined(ENTRYNODES_PRIVATE) */
 
diff --git a/src/or/fp_pair.c b/src/or/fp_pair.c
index f730106d0..c938e7667 100644
--- a/src/or/fp_pair.c
+++ b/src/or/fp_pair.c
@@ -196,7 +196,7 @@ fp_pair_map_remove(fp_pair_map_t *map, const fp_pair_t *key)
  */
 
 void
-fp_pair_map_free(fp_pair_map_t *map, void (*free_val)(void*))
+fp_pair_map_free_(fp_pair_map_t *map, void (*free_val)(void*))
 {
   fp_pair_map_entry_t **ent, **next, *this;
 
diff --git a/src/or/fp_pair.h b/src/or/fp_pair.h
index f7c060b45..4498a1610 100644
--- a/src/or/fp_pair.h
+++ b/src/or/fp_pair.h
@@ -26,7 +26,12 @@ void * fp_pair_map_get(const fp_pair_map_t *map, const fp_pair_t *key);
 void * fp_pair_map_get_by_digests(const fp_pair_map_t *map,
                                   const char *first, const char *second);
 void * fp_pair_map_remove(fp_pair_map_t *map, const fp_pair_t *key);
-void fp_pair_map_free(fp_pair_map_t *map, void (*free_val)(void*));
+void fp_pair_map_free_(fp_pair_map_t *map, void (*free_val)(void*));
+#define fp_pair_map_free(map, free_val) do {            \
+    fp_pair_map_free_((map), (free_val));               \
+    (map) = NULL;                                       \
+  } while (0)
+
 int fp_pair_map_isempty(const fp_pair_map_t *map);
 int fp_pair_map_size(const fp_pair_map_t *map);
 fp_pair_map_iter_t * fp_pair_map_iter_init(fp_pair_map_t *map);
diff --git a/src/or/hs_common.c b/src/or/hs_common.c
index a0f2af29c..fcc524ae1 100644
--- a/src/or/hs_common.c
+++ b/src/or/hs_common.c
@@ -329,7 +329,7 @@ rend_data_alloc(uint32_t version)
 
 /** Free all storage associated with <b>data</b> */
 void
-rend_data_free(rend_data_t *data)
+rend_data_free_(rend_data_t *data)
 {
   if (!data) {
     return;
diff --git a/src/or/hs_common.h b/src/or/hs_common.h
index c95e59a6f..bd20acc9a 100644
--- a/src/or/hs_common.h
+++ b/src/or/hs_common.h
@@ -181,7 +181,8 @@ void hs_build_blinded_keypair(const ed25519_keypair_t *kp,
                               ed25519_keypair_t *kp_out);
 int hs_service_requires_uptime_circ(const smartlist_t *ports);
 
-void rend_data_free(rend_data_t *data);
+void rend_data_free_(rend_data_t *data);
+#define rend_data_free(data) FREE_AND_NULL(rend_data, (data))
 rend_data_t *rend_data_dup(const rend_data_t *data);
 rend_data_t *rend_data_client_create(const char *onion_address,
                                      const char *desc_id,
diff --git a/src/or/hs_descriptor.c b/src/or/hs_descriptor.c
index 170886694..789bc1d04 100644
--- a/src/or/hs_descriptor.c
+++ b/src/or/hs_descriptor.c
@@ -2367,7 +2367,7 @@ hs_desc_encode_descriptor,(const hs_descriptor_t *desc,
 
 /* Free the descriptor plaintext data object. */
 void
-hs_desc_plaintext_data_free(hs_desc_plaintext_data_t *desc)
+hs_desc_plaintext_data_free_(hs_desc_plaintext_data_t *desc)
 {
   desc_plaintext_data_free_contents(desc);
   tor_free(desc);
@@ -2375,7 +2375,7 @@ hs_desc_plaintext_data_free(hs_desc_plaintext_data_t *desc)
 
 /* Free the descriptor encrypted data object. */
 void
-hs_desc_encrypted_data_free(hs_desc_encrypted_data_t *desc)
+hs_desc_encrypted_data_free_(hs_desc_encrypted_data_t *desc)
 {
   desc_encrypted_data_free_contents(desc);
   tor_free(desc);
@@ -2383,7 +2383,7 @@ hs_desc_encrypted_data_free(hs_desc_encrypted_data_t *desc)
 
 /* Free the given descriptor object. */
 void
-hs_descriptor_free(hs_descriptor_t *desc)
+hs_descriptor_free_(hs_descriptor_t *desc)
 {
   if (!desc) {
     return;
@@ -2448,7 +2448,7 @@ hs_desc_intro_point_new(void)
 
 /* Free a descriptor intro point object. */
 void
-hs_desc_intro_point_free(hs_desc_intro_point_t *ip)
+hs_desc_intro_point_free_(hs_desc_intro_point_t *ip)
 {
   if (ip == NULL) {
     return;
@@ -2467,7 +2467,7 @@ hs_desc_intro_point_free(hs_desc_intro_point_t *ip)
 
 /* Free the given descriptor link specifier. */
 void
-hs_desc_link_specifier_free(hs_desc_link_specifier_t *ls)
+hs_desc_link_specifier_free_(hs_desc_link_specifier_t *ls)
 {
   if (ls == NULL) {
     return;
diff --git a/src/or/hs_descriptor.h b/src/or/hs_descriptor.h
index 52bec8e24..5fa180ea5 100644
--- a/src/or/hs_descriptor.h
+++ b/src/or/hs_descriptor.h
@@ -208,11 +208,19 @@ hs_desc_is_supported_version(uint32_t version)
 
 /* Public API. */
 
-void hs_descriptor_free(hs_descriptor_t *desc);
-void hs_desc_plaintext_data_free(hs_desc_plaintext_data_t *desc);
-void hs_desc_encrypted_data_free(hs_desc_encrypted_data_t *desc);
+void hs_descriptor_free_(hs_descriptor_t *desc);
+#define hs_descriptor_free(desc) FREE_AND_NULL(hs_descriptor, (desc))
+void hs_desc_plaintext_data_free_(hs_desc_plaintext_data_t *desc);
+#define hs_desc_plaintext_data_free(desc) \
+  FREE_AND_NULL(hs_desc_plaintext_data, (desc))
+void hs_desc_encrypted_data_free_(hs_desc_encrypted_data_t *desc);
+#define hs_desc_encrypted_data_free(desc) \
+  FREE_AND_NULL(hs_desc_encrypted_data, (desc))
+
+void hs_desc_link_specifier_free_(hs_desc_link_specifier_t *ls);
+#define hs_desc_link_specifier_free(ls) \
+  FREE_AND_NULL(hs_desc_link_specifier, (ls))
 
-void hs_desc_link_specifier_free(hs_desc_link_specifier_t *ls);
 hs_desc_link_specifier_t *hs_desc_link_specifier_new(
                                   const extend_info_t *info, uint8_t type);
 void hs_descriptor_clear_intro_points(hs_descriptor_t *desc);
@@ -234,7 +242,8 @@ size_t hs_desc_obj_size(const hs_descriptor_t *data);
 size_t hs_desc_plaintext_obj_size(const hs_desc_plaintext_data_t *data);
 
 hs_desc_intro_point_t *hs_desc_intro_point_new(void);
-void hs_desc_intro_point_free(hs_desc_intro_point_t *ip);
+void hs_desc_intro_point_free_(hs_desc_intro_point_t *ip);
+#define hs_desc_intro_point_free(ip) FREE_AND_NULL(hs_desc_intro_point, (ip))
 
 link_specifier_t *hs_desc_lspec_to_trunnel(
                                    const hs_desc_link_specifier_t *spec);
diff --git a/src/or/hs_ident.c b/src/or/hs_ident.c
index b0e4e36a9..0bce2f625 100644
--- a/src/or/hs_ident.c
+++ b/src/or/hs_ident.c
@@ -25,7 +25,7 @@ hs_ident_circuit_new(const ed25519_public_key_t *identity_pk,
 
 /* Free the given circuit identifier. */
 void
-hs_ident_circuit_free(hs_ident_circuit_t *ident)
+hs_ident_circuit_free_(hs_ident_circuit_t *ident)
 {
   if (ident == NULL) {
     return;
@@ -56,7 +56,7 @@ hs_ident_dir_conn_dup(const hs_ident_dir_conn_t *src)
 
 /* Free the given directory connection identifier. */
 void
-hs_ident_dir_conn_free(hs_ident_dir_conn_t *ident)
+hs_ident_dir_conn_free_(hs_ident_dir_conn_t *ident)
 {
   if (ident == NULL) {
     return;
@@ -93,7 +93,7 @@ hs_ident_edge_conn_new(const ed25519_public_key_t *identity_pk)
 
 /* Free the given edge connection identifier. */
 void
-hs_ident_edge_conn_free(hs_ident_edge_conn_t *ident)
+hs_ident_edge_conn_free_(hs_ident_edge_conn_t *ident)
 {
   if (ident == NULL) {
     return;
diff --git a/src/or/hs_ident.h b/src/or/hs_ident.h
index 03150d25e..274772ead 100644
--- a/src/or/hs_ident.h
+++ b/src/or/hs_ident.h
@@ -119,12 +119,14 @@ typedef struct hs_ident_edge_conn_t {
 hs_ident_circuit_t *hs_ident_circuit_new(
                              const ed25519_public_key_t *identity_pk,
                              hs_ident_circuit_type_t circuit_type);
-void hs_ident_circuit_free(hs_ident_circuit_t *ident);
+void hs_ident_circuit_free_(hs_ident_circuit_t *ident);
+#define hs_ident_circuit_free(id) FREE_AND_NULL(hs_ident_circuit, (id))
 hs_ident_circuit_t *hs_ident_circuit_dup(const hs_ident_circuit_t *src);
 
 /* Directory connection identifier API. */
 hs_ident_dir_conn_t *hs_ident_dir_conn_dup(const hs_ident_dir_conn_t *src);
-void hs_ident_dir_conn_free(hs_ident_dir_conn_t *ident);
+void hs_ident_dir_conn_free_(hs_ident_dir_conn_t *ident);
+#define hs_ident_dir_conn_free(id) FREE_AND_NULL(hs_ident_dir_conn, (id))
 void hs_ident_dir_conn_init(const ed25519_public_key_t *identity_pk,
                             const ed25519_public_key_t *blinded_pk,
                             hs_ident_dir_conn_t *ident);
@@ -132,7 +134,8 @@ void hs_ident_dir_conn_init(const ed25519_public_key_t *identity_pk,
 /* Edge connection identifier API. */
 hs_ident_edge_conn_t *hs_ident_edge_conn_new(
                                     const ed25519_public_key_t *identity_pk);
-void hs_ident_edge_conn_free(hs_ident_edge_conn_t *ident);
+void hs_ident_edge_conn_free_(hs_ident_edge_conn_t *ident);
+#define hs_ident_edge_conn_free(id) FREE_AND_NULL(hs_ident_edge_conn, (id))
 
 /* Validators */
 int hs_ident_intro_circ_is_valid(const hs_ident_circuit_t *ident);
diff --git a/src/or/hs_service.c b/src/or/hs_service.c
index 8e2f52dcf..e88fb2389 100644
--- a/src/or/hs_service.c
+++ b/src/or/hs_service.c
@@ -352,7 +352,7 @@ service_free_all(void)
 
 /* Free a given service intro point object. */
 STATIC void
-service_intro_point_free(hs_service_intro_point_t *ip)
+service_intro_point_free_(hs_service_intro_point_t *ip)
 {
   if (!ip) {
     return;
@@ -368,7 +368,7 @@ service_intro_point_free(hs_service_intro_point_t *ip)
 /* Helper: free an hs_service_intro_point_t object. This function is used by
  * digest256map_free() which requires a void * pointer. */
 static void
-service_intro_point_free_(void *obj)
+service_intro_point_free_void(void *obj)
 {
   service_intro_point_free(obj);
 }
@@ -1027,7 +1027,7 @@ load_service_keys(hs_service_t *service)
 
 /* Free a given service descriptor object and all key material is wiped. */
 STATIC void
-service_descriptor_free(hs_service_descriptor_t *desc)
+service_descriptor_free_(hs_service_descriptor_t *desc)
 {
   if (!desc) {
     return;
@@ -1036,7 +1036,7 @@ service_descriptor_free(hs_service_descriptor_t *desc)
   memwipe(&desc->signing_kp, 0, sizeof(desc->signing_kp));
   memwipe(&desc->blinded_kp, 0, sizeof(desc->blinded_kp));
   /* Cleanup all intro points. */
-  digest256map_free(desc->intro_points.map, service_intro_point_free_);
+  digest256map_free(desc->intro_points.map, service_intro_point_free_void);
   digestmap_free(desc->intro_points.failed_id, tor_free_);
   if (desc->previous_hsdirs) {
     SMARTLIST_FOREACH(desc->previous_hsdirs, char *, s, tor_free(s));
@@ -3256,7 +3256,7 @@ hs_service_new(const or_options_t *options)
  * also takes care of wiping service keys from memory. It is safe to pass a
  * NULL pointer. */
 void
-hs_service_free(hs_service_t *service)
+hs_service_free_(hs_service_t *service)
 {
   if (service == NULL) {
     return;
diff --git a/src/or/hs_service.h b/src/or/hs_service.h
index ed1053d85..b75903016 100644
--- a/src/or/hs_service.h
+++ b/src/or/hs_service.h
@@ -249,7 +249,8 @@ void hs_service_free_all(void);
 
 /* Service new/free functions. */
 hs_service_t *hs_service_new(const or_options_t *options);
-void hs_service_free(hs_service_t *service);
+void hs_service_free_(hs_service_t *service);
+#define hs_service_free(s) FREE_AND_NULL(hs_service, (s))
 
 unsigned int hs_service_get_num_services(void);
 void hs_service_stage_services(const smartlist_t *service_list);
@@ -274,12 +275,15 @@ void hs_service_intro_circ_has_closed(origin_circuit_t *circ);
 #ifdef HS_SERVICE_PRIVATE
 
 #ifdef TOR_UNIT_TESTS
-
 /* Useful getters for unit tests. */
 STATIC unsigned int get_hs_service_map_size(void);
 STATIC int get_hs_service_staging_list_size(void);
 STATIC hs_service_ht *get_hs_service_map(void);
 STATIC hs_service_t *get_first_service(void);
+STATIC hs_service_intro_point_t *service_intro_point_find_by_ident(
+                                         const hs_service_t *service,
+                                         const hs_ident_circuit_t *ident);
+#endif
 
 /* Service accessors. */
 STATIC hs_service_t *find_service(hs_service_ht *map,
@@ -290,7 +294,9 @@ STATIC int register_service(hs_service_ht *map, hs_service_t *service);
 STATIC hs_service_intro_point_t *service_intro_point_new(
                                          const extend_info_t *ei,
                                          unsigned int is_legacy);
-STATIC void service_intro_point_free(hs_service_intro_point_t *ip);
+STATIC void service_intro_point_free_(hs_service_intro_point_t *ip);
+#define service_intro_point_free(ip)            \
+  FREE_AND_NULL(service_intro_point, (ip))
 STATIC void service_intro_point_add(digest256map_t *map,
                                     hs_service_intro_point_t *ip);
 STATIC void service_intro_point_remove(const hs_service_t *service,
@@ -298,9 +304,6 @@ STATIC void service_intro_point_remove(const hs_service_t *service,
 STATIC hs_service_intro_point_t *service_intro_point_find(
                                  const hs_service_t *service,
                                  const ed25519_public_key_t *auth_key);
-STATIC hs_service_intro_point_t *service_intro_point_find_by_ident(
-                                         const hs_service_t *service,
-                                         const hs_ident_circuit_t *ident);
 /* Service descriptor functions. */
 STATIC hs_service_descriptor_t *service_descriptor_new(void);
 STATIC hs_service_descriptor_t *service_desc_find_by_intro(
@@ -326,7 +329,8 @@ STATIC void run_upload_descriptor_event(time_t now);
 STATIC char *
 encode_desc_rev_counter_for_state(const hs_service_descriptor_t *desc);
 
-STATIC void service_descriptor_free(hs_service_descriptor_t *desc);
+STATIC void service_descriptor_free_(hs_service_descriptor_t *desc);
+#define service_descriptor_free(d) FREE_AND_NULL(service_descriptor, (d))
 
 STATIC uint64_t
 check_state_line_for_service_rev_counter(const char *state_line,
@@ -346,8 +350,6 @@ STATIC void service_desc_schedule_upload(hs_service_descriptor_t *desc,
 STATIC int service_desc_hsdirs_changed(const hs_service_t *service,
                                 const hs_service_descriptor_t *desc);
 
-#endif /* defined(TOR_UNIT_TESTS) */
-
 #endif /* defined(HS_SERVICE_PRIVATE) */
 
 #endif /* !defined(TOR_HS_SERVICE_H) */
diff --git a/src/or/microdesc.h b/src/or/microdesc.h
index 1be12156a..83a90bd8f 100644
--- a/src/or/microdesc.h
+++ b/src/or/microdesc.h
@@ -38,8 +38,10 @@ smartlist_t *microdesc_list_missing_digest256(networkstatus_t *ns,
                                               digest256map_t *skip);
 
 void microdesc_free_(microdesc_t *md, const char *fname, int line);
-#define microdesc_free(md) \
-  microdesc_free_((md), __FILE__, __LINE__)
+#define microdesc_free(md) do {                 \
+    microdesc_free_((md), __FILE__, __LINE__);  \
+    (md) = NULL;                                \
+  } while (0)
 void microdesc_free_all(void);
 
 void update_microdesc_downloads(time_t now);
diff --git a/src/or/networkstatus.c b/src/or/networkstatus.c
index 10d9b7542..d9dedcae8 100644
--- a/src/or/networkstatus.c
+++ b/src/or/networkstatus.c
@@ -255,7 +255,7 @@ router_reload_consensus_networkstatus(void)
 
 /** Free all storage held by the vote_routerstatus object <b>rs</b>. */
 void
-vote_routerstatus_free(vote_routerstatus_t *rs)
+vote_routerstatus_free_(vote_routerstatus_t *rs)
 {
   vote_microdesc_hash_t *h, *next;
   if (!rs)
@@ -273,7 +273,7 @@ vote_routerstatus_free(vote_routerstatus_t *rs)
 
 /** Free all storage held by the routerstatus object <b>rs</b>. */
 void
-routerstatus_free(routerstatus_t *rs)
+routerstatus_free_(routerstatus_t *rs)
 {
   if (!rs)
     return;
@@ -283,7 +283,7 @@ routerstatus_free(routerstatus_t *rs)
 
 /** Free all storage held in <b>sig</b> */
 void
-document_signature_free(document_signature_t *sig)
+document_signature_free_(document_signature_t *sig)
 {
   tor_free(sig->signature);
   tor_free(sig);
@@ -301,7 +301,7 @@ document_signature_dup(const document_signature_t *sig)
 
 /** Free all storage held in <b>ns</b>. */
 void
-networkstatus_vote_free(networkstatus_t *ns)
+networkstatus_vote_free_(networkstatus_t *ns)
 {
   if (!ns)
     return;
diff --git a/src/or/networkstatus.h b/src/or/networkstatus.h
index 39a0f753d..f62b5d240 100644
--- a/src/or/networkstatus.h
+++ b/src/or/networkstatus.h
@@ -18,8 +18,10 @@ void networkstatus_reset_warnings(void);
 void networkstatus_reset_download_failures(void);
 char *networkstatus_read_cached_consensus(const char *flavorname);
 int router_reload_consensus_networkstatus(void);
-void routerstatus_free(routerstatus_t *rs);
-void networkstatus_vote_free(networkstatus_t *ns);
+void routerstatus_free_(routerstatus_t *rs);
+#define routerstatus_free(rs) FREE_AND_NULL(routerstatus, (rs))
+void networkstatus_vote_free_(networkstatus_t *ns);
+#define networkstatus_vote_free(ns) FREE_AND_NULL(networkstatus_vote, (ns))
 networkstatus_voter_info_t *networkstatus_get_voter_by_id(
                                        networkstatus_t *vote,
                                        const char *identity);
@@ -124,12 +126,14 @@ int32_t networkstatus_get_bw_weight(networkstatus_t *ns, const char *weight,
                                     int32_t default_val);
 const char *networkstatus_get_flavor_name(consensus_flavor_t flav);
 int networkstatus_parse_flavor_name(const char *flavname);
-void document_signature_free(document_signature_t *sig);
+void document_signature_free_(document_signature_t *sig);
+#define document_signature_free(sig) FREE_AND_NULL(document_signature, (sig))
 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);
 
-void vote_routerstatus_free(vote_routerstatus_t *rs);
+void vote_routerstatus_free_(vote_routerstatus_t *rs);
+#define vote_routerstatus_free(rs) FREE_AND_NULL(vote_routerstatus, (rs))
 
 #ifdef NETWORKSTATUS_PRIVATE
 #ifdef TOR_UNIT_TESTS
diff --git a/src/or/onion.c b/src/or/onion.c
index 7e1e89df1..bd80c2f50 100644
--- a/src/or/onion.c
+++ b/src/or/onion.c
@@ -423,7 +423,7 @@ server_onion_keys_new(void)
 
 /** Release all storage held in <b>keys</b>. */
 void
-server_onion_keys_free(server_onion_keys_t *keys)
+server_onion_keys_free_(server_onion_keys_t *keys)
 {
   if (! keys)
     return;
diff --git a/src/or/onion.h b/src/or/onion.h
index 95544dfac..559cbb881 100644
--- a/src/or/onion.h
+++ b/src/or/onion.h
@@ -31,7 +31,8 @@ typedef struct server_onion_keys_t {
 #define MAX_ONIONSKIN_REPLY_LEN 255
 
 server_onion_keys_t *server_onion_keys_new(void);
-void server_onion_keys_free(server_onion_keys_t *keys);
+void server_onion_keys_free_(server_onion_keys_t *keys);
+#define server_onion_keys_free(keys) FREE_AND_NULL(server_onion_keys, (keys))
 
 void onion_handshake_state_release(onion_handshake_state_t *state);
 
diff --git a/src/or/onion_fast.c b/src/or/onion_fast.c
index 146943a27..56c954829 100644
--- a/src/or/onion_fast.c
+++ b/src/or/onion_fast.c
@@ -32,7 +32,7 @@
 
 /** Release all state held in <b>victim</b>. */
 void
-fast_handshake_state_free(fast_handshake_state_t *victim)
+fast_handshake_state_free_(fast_handshake_state_t *victim)
 {
   if (! victim)
     return;
diff --git a/src/or/onion_fast.h b/src/or/onion_fast.h
index 3a5aefea3..7d110fd75 100644
--- a/src/or/onion_fast.h
+++ b/src/or/onion_fast.h
@@ -19,7 +19,9 @@ typedef struct fast_handshake_state_t {
   uint8_t state[DIGEST_LEN];
 } fast_handshake_state_t;
 
-void fast_handshake_state_free(fast_handshake_state_t *victim);
+void fast_handshake_state_free_(fast_handshake_state_t *victim);
+#define fast_handshake_state_free(st) \
+  FREE_AND_NULL(fast_handshake_state, (st))
 
 int fast_onionskin_create(fast_handshake_state_t **handshake_state_out,
                           uint8_t *handshake_out);
diff --git a/src/or/onion_ntor.c b/src/or/onion_ntor.c
index 902260b54..b167cb61f 100644
--- a/src/or/onion_ntor.c
+++ b/src/or/onion_ntor.c
@@ -28,7 +28,7 @@
 
 /** Free storage held in an ntor handshake state. */
 void
-ntor_handshake_state_free(ntor_handshake_state_t *state)
+ntor_handshake_state_free_(ntor_handshake_state_t *state)
 {
   if (!state)
     return;
diff --git a/src/or/onion_ntor.h b/src/or/onion_ntor.h
index 02dea2dfc..6ca9395dc 100644
--- a/src/or/onion_ntor.h
+++ b/src/or/onion_ntor.h
@@ -17,7 +17,9 @@ typedef struct ntor_handshake_state_t ntor_handshake_state_t;
 /** Length of an ntor reply, as sent from server to client. */
 #define NTOR_REPLY_LEN 64
 
-void ntor_handshake_state_free(ntor_handshake_state_t *state);
+void ntor_handshake_state_free_(ntor_handshake_state_t *state);
+#define ntor_handshake_state_free(state) \
+  FREE_AND_NULL(ntor_handshake_state, (state))
 
 int onion_skin_ntor_create(const uint8_t *router_id,
                            const curve25519_public_key_t *router_key,
diff --git a/src/or/policies.c b/src/or/policies.c
index 2e584095d..fc033c559 100644
--- a/src/or/policies.c
+++ b/src/or/policies.c
@@ -2794,7 +2794,7 @@ write_short_policy(const short_policy_t *policy)
 
 /** Release all storage held in <b>policy</b>. */
 void
-short_policy_free(short_policy_t *policy)
+short_policy_free_(short_policy_t *policy)
 {
   tor_free(policy);
 }
@@ -3044,7 +3044,7 @@ getinfo_helper_policies(control_connection_t *conn,
 
 /** Release all storage held by <b>p</b>. */
 void
-addr_policy_list_free(smartlist_t *lst)
+addr_policy_list_free_(smartlist_t *lst)
 {
   if (!lst)
     return;
@@ -3054,7 +3054,7 @@ addr_policy_list_free(smartlist_t *lst)
 
 /** Release all storage held by <b>p</b>. */
 void
-addr_policy_free(addr_policy_t *p)
+addr_policy_free_(addr_policy_t *p)
 {
   if (!p)
     return;
diff --git a/src/or/policies.h b/src/or/policies.h
index cd97ee7f5..062f33018 100644
--- a/src/or/policies.h
+++ b/src/or/policies.h
@@ -115,15 +115,18 @@ int getinfo_helper_policies(control_connection_t *conn,
 int policy_write_item(char *buf, size_t buflen, const addr_policy_t *item,
                       int format_for_desc);
 
-void addr_policy_list_free(smartlist_t *p);
-void addr_policy_free(addr_policy_t *p);
+void addr_policy_list_free_(smartlist_t *p);
+#define addr_policy_list_free(lst) FREE_AND_NULL(addr_policy_list, (lst))
+void addr_policy_free_(addr_policy_t *p);
+#define addr_policy_free(p) FREE_AND_NULL(addr_policy, (p))
 void policies_free_all(void);
 
 char *policy_summarize(smartlist_t *policy, sa_family_t family);
 
 short_policy_t *parse_short_policy(const char *summary);
 char *write_short_policy(const short_policy_t *policy);
-void short_policy_free(short_policy_t *policy);
+void short_policy_free_(short_policy_t *policy);
+#define short_policy_free(p) FREE_AND_NULL(short_policy, (p))
 int short_policy_is_reject_star(const short_policy_t *policy);
 addr_policy_result_t compare_tor_addr_to_short_policy(
                           const tor_addr_t *addr, uint16_t port,
diff --git a/src/or/proto_socks.c b/src/or/proto_socks.c
index 7649fcc4b..91633d02a 100644
--- a/src/or/proto_socks.c
+++ b/src/or/proto_socks.c
@@ -66,7 +66,7 @@ socks_request_new(void)
 
 /** Free all storage held in the socks_request_t <b>req</b>. */
 void
-socks_request_free(socks_request_t *req)
+socks_request_free_(socks_request_t *req)
 {
   if (!req)
     return;
diff --git a/src/or/proto_socks.h b/src/or/proto_socks.h
index a71415141..423362cde 100644
--- a/src/or/proto_socks.h
+++ b/src/or/proto_socks.h
@@ -11,7 +11,8 @@ struct socks_request_t;
 struct buf_t;
 
 struct socks_request_t *socks_request_new(void);
-void socks_request_free(struct socks_request_t *req);
+void socks_request_free_(struct socks_request_t *req);
+#define socks_request_free(req) FREE_AND_NULL(socks_request, (req))
 int fetch_from_buf_socks(struct buf_t *buf, socks_request_t *req,
                          int log_sockstype, int safe_socks);
 int fetch_from_buf_socks_client(buf_t *buf, int state, char **reason);
diff --git a/src/or/protover.c b/src/or/protover.c
index ae955296e..36353e902 100644
--- a/src/or/protover.c
+++ b/src/or/protover.c
@@ -96,7 +96,7 @@ str_to_protocol_type(const char *s, protocol_type_t *pr_out)
  * Release all space held by a single proto_entry_t structure
  */
 STATIC void
-proto_entry_free(proto_entry_t *entry)
+proto_entry_free_(proto_entry_t *entry)
 {
   if (!entry)
     return;
diff --git a/src/or/protover.h b/src/or/protover.h
index a4dbc8bfc..99e86d76b 100644
--- a/src/or/protover.h
+++ b/src/or/protover.h
@@ -82,9 +82,9 @@ STATIC smartlist_t *parse_protocol_list(const char *s);
 STATIC char *encode_protocol_list(const smartlist_t *sl);
 STATIC const char *protocol_type_to_str(protocol_type_t pr);
 STATIC int str_to_protocol_type(const char *s, protocol_type_t *pr_out);
-STATIC void proto_entry_free(proto_entry_t *entry);
-
+STATIC void proto_entry_free_(proto_entry_t *entry);
 #endif
+#define proto_entry_free(entry) FREE_AND_NULL(proto_entry, (entry))
 
 #endif /* defined(PROTOVER_PRIVATE) */
 
diff --git a/src/or/relay.c b/src/or/relay.c
index 09f70793d..914ed219c 100644
--- a/src/or/relay.c
+++ b/src/or/relay.c
@@ -1158,7 +1158,7 @@ connected_cell_parse(const relay_header_t *rh, const cell_t *cell,
 
 /** Drop all storage held by <b>addr</b>. */
 STATIC void
-address_ttl_free(address_ttl_t *addr)
+address_ttl_free_(address_ttl_t *addr)
 {
   if (!addr)
     return;
@@ -2425,7 +2425,7 @@ packed_cell_new(void)
 
 /** Return a packed cell used outside by channel_t lower layer */
 void
-packed_cell_free(packed_cell_t *cell)
+packed_cell_free_(packed_cell_t *cell)
 {
   if (!cell)
     return;
diff --git a/src/or/relay.h b/src/or/relay.h
index 2412dcb23..9f66aacdd 100644
--- a/src/or/relay.h
+++ b/src/or/relay.h
@@ -51,7 +51,8 @@ size_t packed_cell_mem_cost(void);
 int have_been_under_memory_pressure(void);
 
 /* For channeltls.c */
-void packed_cell_free(packed_cell_t *cell);
+void packed_cell_free_(packed_cell_t *cell);
+#define packed_cell_free(cell) FREE_AND_NULL(packed_cell, (cell))
 
 void cell_queue_init(cell_queue_t *queue);
 void cell_queue_clear(cell_queue_t *queue);
@@ -94,7 +95,8 @@ typedef struct address_ttl_s {
   char *hostname;
   int ttl;
 } address_ttl_t;
-STATIC void address_ttl_free(address_ttl_t *addr);
+STATIC void address_ttl_free_(address_ttl_t *addr);
+#define address_ttl_free(addr) FREE_AND_NULL(address_ttl, (addr))
 STATIC int resolved_cell_parse(const cell_t *cell, const relay_header_t *rh,
                                smartlist_t *addresses_out, int *errcode_out);
 STATIC int connection_edge_process_resolved_cell(edge_connection_t *conn,
diff --git a/src/or/rendcache.c b/src/or/rendcache.c
index b98b2bccf..fa454321d 100644
--- a/src/or/rendcache.c
+++ b/src/or/rendcache.c
@@ -120,7 +120,7 @@ rend_cache_increment_allocation(size_t n)
 
 /** Helper: free a rend cache failure intro object. */
 STATIC void
-rend_cache_failure_intro_entry_free(rend_cache_failure_intro_t *entry)
+rend_cache_failure_intro_entry_free_(rend_cache_failure_intro_t *entry)
 {
   if (entry == NULL) {
     return;
@@ -129,7 +129,7 @@ rend_cache_failure_intro_entry_free(rend_cache_failure_intro_t *entry)
 }
 
 static void
-rend_cache_failure_intro_entry_free_(void *entry)
+rend_cache_failure_intro_entry_free_void(void *entry)
 {
   rend_cache_failure_intro_entry_free(entry);
 }
@@ -147,7 +147,7 @@ rend_cache_failure_intro_entry_new(rend_intro_point_failure_t failure)
 
 /** Helper: free a rend cache failure object. */
 STATIC void
-rend_cache_failure_entry_free(rend_cache_failure_t *entry)
+rend_cache_failure_entry_free_(rend_cache_failure_t *entry)
 {
   if (entry == NULL) {
     return;
@@ -155,7 +155,7 @@ rend_cache_failure_entry_free(rend_cache_failure_t *entry)
 
   /* Free and remove every intro failure object. */
   digestmap_free(entry->intro_failures,
-                 rend_cache_failure_intro_entry_free_);
+                 rend_cache_failure_intro_entry_free_void);
 
   tor_free(entry);
 }
@@ -163,7 +163,7 @@ rend_cache_failure_entry_free(rend_cache_failure_t *entry)
 /** Helper: deallocate a rend_cache_failure_t. (Used with strmap_free(),
  * which requires a function pointer whose argument is void*). */
 STATIC void
-rend_cache_failure_entry_free_(void *entry)
+rend_cache_failure_entry_free_void(void *entry)
 {
   rend_cache_failure_entry_free(entry);
 }
@@ -201,7 +201,7 @@ rend_cache_failure_remove(rend_service_descriptor_t *desc)
 
 /** Helper: free storage held by a single service descriptor cache entry. */
 STATIC void
-rend_cache_entry_free(rend_cache_entry_t *e)
+rend_cache_entry_free_(rend_cache_entry_t *e)
 {
   if (!e)
     return;
@@ -217,7 +217,7 @@ rend_cache_entry_free(rend_cache_entry_t *e)
 /** Helper: deallocate a rend_cache_entry_t.  (Used with strmap_free(), which
  * requires a function pointer whose argument is void*). */
 static void
-rend_cache_entry_free_(void *p)
+rend_cache_entry_free_void(void *p)
 {
   rend_cache_entry_free(p);
 }
@@ -226,10 +226,10 @@ rend_cache_entry_free_(void *p)
 void
 rend_cache_free_all(void)
 {
-  strmap_free(rend_cache, rend_cache_entry_free_);
-  digestmap_free(rend_cache_v2_dir, rend_cache_entry_free_);
-  strmap_free(rend_cache_local_service, rend_cache_entry_free_);
-  strmap_free(rend_cache_failure, rend_cache_failure_entry_free_);
+  strmap_free(rend_cache, rend_cache_entry_free_void);
+  digestmap_free(rend_cache_v2_dir, rend_cache_entry_free_void);
+  strmap_free(rend_cache_local_service, rend_cache_entry_free_void);
+  strmap_free(rend_cache_failure, rend_cache_failure_entry_free_void);
   rend_cache = NULL;
   rend_cache_v2_dir = NULL;
   rend_cache_local_service = NULL;
@@ -304,7 +304,7 @@ rend_cache_purge(void)
 {
   if (rend_cache) {
     log_info(LD_REND, "Purging HS v2 descriptor cache");
-    strmap_free(rend_cache, rend_cache_entry_free_);
+    strmap_free(rend_cache, rend_cache_entry_free_void);
   }
   rend_cache = strmap_new();
 }
@@ -316,7 +316,7 @@ rend_cache_failure_purge(void)
 {
   if (rend_cache_failure) {
     log_info(LD_REND, "Purging HS v2 failure cache");
-    strmap_free(rend_cache_failure, rend_cache_failure_entry_free_);
+    strmap_free(rend_cache_failure, rend_cache_failure_entry_free_void);
   }
   rend_cache_failure = strmap_new();
 }
diff --git a/src/or/rendcache.h b/src/or/rendcache.h
index 5b13eadfa..66b48e032 100644
--- a/src/or/rendcache.h
+++ b/src/or/rendcache.h
@@ -90,10 +90,15 @@ void rend_cache_increment_allocation(size_t n);
 #ifdef RENDCACHE_PRIVATE
 
 STATIC size_t rend_cache_entry_allocation(const rend_cache_entry_t *e);
-STATIC void rend_cache_entry_free(rend_cache_entry_t *e);
-STATIC void rend_cache_failure_intro_entry_free(rend_cache_failure_intro_t
-                                                *entry);
-STATIC void rend_cache_failure_entry_free(rend_cache_failure_t *entry);
+STATIC void rend_cache_entry_free_(rend_cache_entry_t *e);
+#define rend_cache_entry_free(e) FREE_AND_NULL(rend_cache_entry, (e))
+STATIC void rend_cache_failure_intro_entry_free_(rend_cache_failure_intro_t
+                                                 *entry);
+#define rend_cache_failure_intro_entry_free(e) \
+  FREE_AND_NULL(rend_cache_failure_intro_entry, (e))
+STATIC void rend_cache_failure_entry_free_(rend_cache_failure_t *entry);
+#define rend_cache_failure_entry_free(e) \
+  FREE_AND_NULL(rend_cache_failure_entry, (e))
 STATIC int cache_failure_intro_lookup(const uint8_t *identity,
                                       const char *service_id,
                                       rend_cache_failure_intro_t
@@ -108,7 +113,7 @@ STATIC void cache_failure_intro_add(const uint8_t *identity,
 STATIC void validate_intro_point_failure(const rend_service_descriptor_t *desc,
                                         const char *service_id);
 
-STATIC void rend_cache_failure_entry_free_(void *entry);
+STATIC void rend_cache_failure_entry_free_void(void *entry);
 
 #ifdef TOR_UNIT_TESTS
 extern strmap_t *rend_cache;
diff --git a/src/or/rendcommon.c b/src/or/rendcommon.c
index 458a90058..230da4be5 100644
--- a/src/or/rendcommon.c
+++ b/src/or/rendcommon.c
@@ -37,7 +37,7 @@ rend_cmp_service_ids(const char *one, const char *two)
 /** Free the storage held by the service descriptor <b>desc</b>.
  */
 void
-rend_service_descriptor_free(rend_service_descriptor_t *desc)
+rend_service_descriptor_free_(rend_service_descriptor_t *desc)
 {
   if (!desc)
     return;
@@ -419,7 +419,7 @@ rend_desc_v2_is_parsable(rend_encoded_v2_service_descriptor_t *desc)
 
 /** Free the storage held by an encoded v2 service descriptor. */
 void
-rend_encoded_v2_service_descriptor_free(
+rend_encoded_v2_service_descriptor_free_(
   rend_encoded_v2_service_descriptor_t *desc)
 {
   if (!desc)
@@ -430,7 +430,7 @@ rend_encoded_v2_service_descriptor_free(
 
 /** Free the storage held by an introduction point info. */
 void
-rend_intro_point_free(rend_intro_point_t *intro)
+rend_intro_point_free_(rend_intro_point_t *intro)
 {
   if (!intro)
     return;
diff --git a/src/or/rendcommon.h b/src/or/rendcommon.h
index c35d7272f..159754115 100644
--- a/src/or/rendcommon.h
+++ b/src/or/rendcommon.h
@@ -24,11 +24,16 @@ void rend_process_relay_cell(circuit_t *circ, const crypt_path_t *layer_hint,
                              int command, size_t length,
                              const uint8_t *payload);
 
-void rend_service_descriptor_free(rend_service_descriptor_t *desc);
+void rend_service_descriptor_free_(rend_service_descriptor_t *desc);
+#define rend_service_descriptor_free(desc) \
+  FREE_AND_NULL(rend_service_descriptor, (desc))
 int rend_get_service_id(crypto_pk_t *pk, char *out);
-void rend_encoded_v2_service_descriptor_free(
+void rend_encoded_v2_service_descriptor_free_(
                                rend_encoded_v2_service_descriptor_t *desc);
-void rend_intro_point_free(rend_intro_point_t *intro);
+#define rend_encoded_v2_service_descriptor_free(desc) \
+  FREE_AND_NULL(rend_encoded_v2_service_descriptor, (desc))
+void rend_intro_point_free_(rend_intro_point_t *intro);
+#define rend_intro_point_free(intro) FREE_AND_NULL(rend_intro_point, (intro))
 
 int rend_valid_v2_service_id(const char *query);
 int rend_valid_descriptor_id(const char *query);
diff --git a/src/or/rendservice.c b/src/or/rendservice.c
index 60234a5c1..568afe79b 100644
--- a/src/or/rendservice.c
+++ b/src/or/rendservice.c
@@ -157,7 +157,7 @@ rend_num_services(void)
 
 /** Helper: free storage held by a single service authorized client entry. */
 void
-rend_authorized_client_free(rend_authorized_client_t *client)
+rend_authorized_client_free_(rend_authorized_client_t *client)
 {
   if (!client)
     return;
@@ -180,7 +180,7 @@ rend_authorized_client_strmap_item_free(void *authorized_client)
 /** Release the storage held by <b>service</b>.
  */
 STATIC void
-rend_service_free(rend_service_t *service)
+rend_service_free_(rend_service_t *service)
 {
   if (!service)
     return;
@@ -470,7 +470,7 @@ rend_service_parse_port_config(const char *string, const char *sep,
 
 /** Release all storage held in a rend_service_port_config_t. */
 void
-rend_service_port_config_free(rend_service_port_config_t *p)
+rend_service_port_config_free_(rend_service_port_config_t *p)
 {
   tor_free(p);
 }
@@ -2221,7 +2221,7 @@ find_rp_for_intro(const rend_intro_cell_t *intro,
  * rend_service_parse_intro().
  */
 void
-rend_service_free_intro(rend_intro_cell_t *request)
+rend_service_free_intro_(rend_intro_cell_t *request)
 {
   if (!request) {
     return;
diff --git a/src/or/rendservice.h b/src/or/rendservice.h
index 5946e3186..7e9a5d6c5 100644
--- a/src/or/rendservice.h
+++ b/src/or/rendservice.h
@@ -117,7 +117,8 @@ typedef struct rend_service_t {
   int max_streams_close_circuit;
 } rend_service_t;
 
-STATIC void rend_service_free(rend_service_t *service);
+STATIC void rend_service_free_(rend_service_t *service);
+#define rend_service_free(s) FREE_AND_NULL(rend_service, (s))
 STATIC char *rend_service_sos_poison_path(const rend_service_t *service);
 STATIC int rend_service_verify_single_onion_poison(
                                                   const rend_service_t *s,
@@ -160,7 +161,11 @@ int rend_service_receive_introduction(origin_circuit_t *circuit,
 int rend_service_decrypt_intro(rend_intro_cell_t *request,
                                crypto_pk_t *key,
                                char **err_msg_out);
-void rend_service_free_intro(rend_intro_cell_t *request);
+void rend_service_free_intro_(rend_intro_cell_t *request);
+#define rend_service_free_intro(req) do {       \
+    rend_service_free_intro_(req);              \
+    (req) = NULL;                               \
+  } while (0)
 rend_intro_cell_t * rend_service_begin_parse_intro(const uint8_t *request,
                                                    size_t request_len,
                                                    uint8_t type,
@@ -183,9 +188,13 @@ void rend_service_init(void);
 rend_service_port_config_t *rend_service_parse_port_config(const char *string,
                                                            const char *sep,
                                                            char **err_msg_out);
-void rend_service_port_config_free(rend_service_port_config_t *p);
+void rend_service_port_config_free_(rend_service_port_config_t *p);
+#define rend_service_port_config_free(p) \
+  FREE_AND_NULL(rend_service_port_config, (p))
 
-void rend_authorized_client_free(rend_authorized_client_t *client);
+void rend_authorized_client_free_(rend_authorized_client_t *client);
+#define rend_authorized_client_free(client) \
+  FREE_AND_NULL(rend_authorized_client, (client))
 
 /** Return value from rend_service_add_ephemeral. */
 typedef enum {
diff --git a/src/or/replaycache.c b/src/or/replaycache.c
index 3d42deb90..4a56bfd7d 100644
--- a/src/or/replaycache.c
+++ b/src/or/replaycache.c
@@ -28,7 +28,7 @@
  */
 
 void
-replaycache_free(replaycache_t *r)
+replaycache_free_(replaycache_t *r)
 {
   if (!r) {
     log_info(LD_BUG, "replaycache_free() called on NULL");
diff --git a/src/or/replaycache.h b/src/or/replaycache.h
index 1cae3497a..8f9db8c2b 100644
--- a/src/or/replaycache.h
+++ b/src/or/replaycache.h
@@ -33,7 +33,8 @@ struct replaycache_s {
 
 /* replaycache_t free/new */
 
-void replaycache_free(replaycache_t *r);
+void replaycache_free_(replaycache_t *r);
+#define replaycache_free(r) FREE_AND_NULL(replaycache, (r))
 replaycache_t * replaycache_new(time_t horizon, time_t interval);
 
 #ifdef REPLAYCACHE_PRIVATE
diff --git a/src/or/router.c b/src/or/router.c
index 614d76a36..8e9b1cd8e 100644
--- a/src/or/router.c
+++ b/src/or/router.c
@@ -233,7 +233,7 @@ ntor_key_map_free_helper(void *arg)
 }
 /** Release all storage from a keymap returned by construct_ntor_key_map. */
 void
-ntor_key_map_free(di_digest256_map_t *map)
+ntor_key_map_free_(di_digest256_map_t *map)
 {
   if (!map)
     return;
diff --git a/src/or/router.h b/src/or/router.h
index 335140091..cd953da7a 100644
--- a/src/or/router.h
+++ b/src/or/router.h
@@ -36,7 +36,8 @@ int get_onion_key_lifetime(void);
 int get_onion_key_grace_period(void);
 
 di_digest256_map_t *construct_ntor_key_map(void);
-void ntor_key_map_free(di_digest256_map_t *map);
+void ntor_key_map_free_(di_digest256_map_t *map);
+#define ntor_key_map_free(map) FREE_AND_NULL(ntor_key_map, (map))
 
 int router_initialize_tls_context(void);
 int init_keys(void);
diff --git a/src/or/routerlist.c b/src/or/routerlist.c
index 50d5cc1ab..877479969 100644
--- a/src/or/routerlist.c
+++ b/src/or/routerlist.c
@@ -463,7 +463,7 @@ cert_list_free(cert_list_t *cl)
 
 /** Wrapper for cert_list_free so we can pass it to digestmap_free */
 static void
-cert_list_free_(void *cl)
+cert_list_free_void(void *cl)
 {
   cert_list_free(cl);
 }
@@ -3168,7 +3168,7 @@ router_get_routerlist(void)
 
 /** Free all storage held by <b>router</b>. */
 void
-routerinfo_free(routerinfo_t *router)
+routerinfo_free_(routerinfo_t *router)
 {
   if (!router)
     return;
@@ -3198,7 +3198,7 @@ routerinfo_free(routerinfo_t *router)
 
 /** Release all storage held by <b>extrainfo</b> */
 void
-extrainfo_free(extrainfo_t *extrainfo)
+extrainfo_free_(extrainfo_t *extrainfo)
 {
   if (!extrainfo)
     return;
@@ -3266,21 +3266,21 @@ signed_descriptor_from_routerinfo(routerinfo_t *ri)
 
 /** Helper: free the storage held by the extrainfo_t in <b>e</b>. */
 static void
-extrainfo_free_(void *e)
+extrainfo_free_void(void *e)
 {
   extrainfo_free(e);
 }
 
 /** Free all storage held by a routerlist <b>rl</b>. */
 void
-routerlist_free(routerlist_t *rl)
+routerlist_free_(routerlist_t *rl)
 {
   if (!rl)
     return;
   rimap_free(rl->identity_map, NULL);
   sdmap_free(rl->desc_digest_map, NULL);
   sdmap_free(rl->desc_by_eid_map, NULL);
-  eimap_free(rl->extra_info_map, extrainfo_free_);
+  eimap_free(rl->extra_info_map, extrainfo_free_void);
   SMARTLIST_FOREACH(rl->routers, routerinfo_t *, r,
                     routerinfo_free(r));
   SMARTLIST_FOREACH(rl->old_routers, signed_descriptor_t *, sd,
@@ -3772,7 +3772,7 @@ routerlist_free_all(void)
   smartlist_free(fallback_dir_servers);
   trusted_dir_servers = fallback_dir_servers = NULL;
   if (trusted_dir_certs) {
-    digestmap_free(trusted_dir_certs, cert_list_free_);
+    digestmap_free(trusted_dir_certs, cert_list_free_void);
     trusted_dir_certs = NULL;
   }
 }
@@ -4740,7 +4740,7 @@ dir_server_add(dir_server_t *ent)
 
 /** Free storage held in <b>cert</b>. */
 void
-authority_cert_free(authority_cert_t *cert)
+authority_cert_free_(authority_cert_t *cert)
 {
   if (!cert)
     return;
diff --git a/src/or/routerlist.h b/src/or/routerlist.h
index 8384c7eb8..18f0670ea 100644
--- a/src/or/routerlist.h
+++ b/src/or/routerlist.h
@@ -96,9 +96,12 @@ MOCK_DECL(signed_descriptor_t *,extrainfo_get_by_descriptor_digest,
 const char *signed_descriptor_get_body(const signed_descriptor_t *desc);
 const char *signed_descriptor_get_annotations(const signed_descriptor_t *desc);
 routerlist_t *router_get_routerlist(void);
-void routerinfo_free(routerinfo_t *router);
-void extrainfo_free(extrainfo_t *extrainfo);
-void routerlist_free(routerlist_t *rl);
+void routerinfo_free_(routerinfo_t *router);
+#define routerinfo_free(router) FREE_AND_NULL(routerinfo, (router))
+void extrainfo_free_(extrainfo_t *extrainfo);
+#define extrainfo_free(ei) FREE_AND_NULL(extrainfo, (ei))
+void routerlist_free_(routerlist_t *rl);
+#define routerlist_free(rl) FREE_AND_NULL(routerlist, (rl))
 void dump_routerlist_mem_usage(int severity);
 void routerlist_remove(routerlist_t *rl, routerinfo_t *ri, int make_old,
                        time_t now);
@@ -191,7 +194,8 @@ dir_server_t *fallback_dir_server_new(const tor_addr_t *addr,
                                       const char *id_digest, double weight);
 void dir_server_add(dir_server_t *ent);
 
-void authority_cert_free(authority_cert_t *cert);
+void authority_cert_free_(authority_cert_t *cert);
+#define authority_cert_free(cert) FREE_AND_NULL(authority_cert, (cert))
 void clear_dir_servers(void);
 void update_consensus_router_descriptor_downloads(time_t now, int is_vote,
                                                   networkstatus_t *consensus);
diff --git a/src/or/routerset.c b/src/or/routerset.c
index 54e26ef94..a2599b316 100644
--- a/src/or/routerset.c
+++ b/src/or/routerset.c
@@ -437,7 +437,7 @@ routerset_equal(const routerset_t *old, const routerset_t *new)
 
 /** Free all storage held in <b>routerset</b>. */
 void
-routerset_free(routerset_t *routerset)
+routerset_free_(routerset_t *routerset)
 {
   if (!routerset)
     return;
diff --git a/src/or/routerset.h b/src/or/routerset.h
index d8819ef3f..57b03fda3 100644
--- a/src/or/routerset.h
+++ b/src/or/routerset.h
@@ -40,7 +40,8 @@ void routerset_subtract_nodes(smartlist_t *out,
 
 char *routerset_to_string(const routerset_t *routerset);
 int routerset_equal(const routerset_t *old, const routerset_t *new);
-void routerset_free(routerset_t *routerset);
+void routerset_free_(routerset_t *routerset);
+#define routerset_free(rs) FREE_AND_NULL(routerset, (rs))
 int routerset_len(const routerset_t *set);
 
 #ifdef ROUTERSET_PRIVATE
diff --git a/src/or/shared_random.c b/src/or/shared_random.c
index b3f62a8fd..72a7aae13 100644
--- a/src/or/shared_random.c
+++ b/src/or/shared_random.c
@@ -897,7 +897,7 @@ sr_srv_encode(char *dst, size_t dst_len, const sr_srv_t *srv)
 
 /* Free a commit object. */
 void
-sr_commit_free(sr_commit_t *commit)
+sr_commit_free_(sr_commit_t *commit)
 {
   if (commit == NULL) {
     return;
diff --git a/src/or/shared_random.h b/src/or/shared_random.h
index c0992489c..125d50260 100644
--- a/src/or/shared_random.h
+++ b/src/or/shared_random.h
@@ -113,7 +113,8 @@ sr_srv_t *sr_parse_srv(const smartlist_t *args);
 char *sr_get_string_for_vote(void);
 char *sr_get_string_for_consensus(const smartlist_t *votes,
                                   int32_t num_srv_agreements);
-void sr_commit_free(sr_commit_t *commit);
+void sr_commit_free_(sr_commit_t *commit);
+#define sr_commit_free(sr) FREE_AND_NULL(sr_commit, (sr))
 void sr_srv_encode(char *dst, size_t dst_len, const sr_srv_t *srv);
 
 /* Private methods (only used by shared_random_state.c): */
diff --git a/src/or/statefile.c b/src/or/statefile.c
index 97bd9cac3..cc114f0a2 100644
--- a/src/or/statefile.c
+++ b/src/or/statefile.c
@@ -681,7 +681,7 @@ save_transport_to_state(const char *transport,
 }
 
 STATIC void
-or_state_free(or_state_t *state)
+or_state_free_(or_state_t *state)
 {
   if (!state)
     return;
diff --git a/src/or/statefile.h b/src/or/statefile.h
index 574afb362..d1b9674d4 100644
--- a/src/or/statefile.h
+++ b/src/or/statefile.h
@@ -20,7 +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 void or_state_free_(or_state_t *state);
+#define or_state_free(st) FREE_AND_NULL(or_state, (st))
 STATIC or_state_t *or_state_new(void);
 #endif
 
diff --git a/src/or/torcert.c b/src/or/torcert.c
index befb39d6e..bd677d1f4 100644
--- a/src/or/torcert.c
+++ b/src/or/torcert.c
@@ -137,7 +137,7 @@ tor_cert_create(const ed25519_keypair_t *signing_key,
 
 /** Release all storage held for <b>cert</b>. */
 void
-tor_cert_free(tor_cert_t *cert)
+tor_cert_free_(tor_cert_t *cert)
 {
   if (! cert)
     return;
@@ -453,7 +453,7 @@ or_handshake_certs_new(void)
 
 /** Release all storage held in <b>certs</b> */
 void
-or_handshake_certs_free(or_handshake_certs_t *certs)
+or_handshake_certs_free_(or_handshake_certs_t *certs)
 {
   if (!certs)
     return;
diff --git a/src/or/torcert.h b/src/or/torcert.h
index c77ae2089..8e8e6e186 100644
--- a/src/or/torcert.h
+++ b/src/or/torcert.h
@@ -57,7 +57,8 @@ tor_cert_t *tor_cert_create(const ed25519_keypair_t *signing_key,
 
 tor_cert_t *tor_cert_parse(const uint8_t *cert, size_t certlen);
 
-void tor_cert_free(tor_cert_t *cert);
+void tor_cert_free_(tor_cert_t *cert);
+#define tor_cert_free(cert) FREE_AND_NULL(tor_cert, (cert))
 
 int tor_cert_get_checkable_sig(ed25519_checkable_t *checkable_out,
                                const tor_cert_t *out,
@@ -83,7 +84,9 @@ rsa_ed25519_crosscert_check, (const uint8_t *crosscert,
                               const time_t reject_if_expired_before));
 
 or_handshake_certs_t *or_handshake_certs_new(void);
-void or_handshake_certs_free(or_handshake_certs_t *certs);
+void or_handshake_certs_free_(or_handshake_certs_t *certs);
+#define or_handshake_certs_free(certs) \
+  FREE_AND_NULL(or_handshake_certs, (certs))
 int or_handshake_certs_rsa_ok(int severity,
                               or_handshake_certs_t *certs,
                               tor_tls_t *tls,
diff --git a/src/or/transports.c b/src/or/transports.c
index 68d135484..04b24b0f8 100644
--- a/src/or/transports.c
+++ b/src/or/transports.c
@@ -154,7 +154,7 @@ transport_new(const tor_addr_t *addr, uint16_t port,
 
 /** Free the pluggable transport struct <b>transport</b>. */
 void
-transport_free(transport_t *transport)
+transport_free_(transport_t *transport)
 {
   if (!transport)
     return;
diff --git a/src/or/transports.h b/src/or/transports.h
index e368e447c..9f348f58e 100644
--- a/src/or/transports.h
+++ b/src/or/transports.h
@@ -35,7 +35,8 @@ void sweep_transport_list(void);
 MOCK_DECL(int, transport_add_from_config,
           (const tor_addr_t *addr, uint16_t port,
            const char *name, int socks_ver));
-void transport_free(transport_t *transport);
+void transport_free_(transport_t *transport);
+#define transport_free(tr) FREE_AND_NULL(transport, (tr))
 
 transport_t *transport_get_by_name(const char *name);
 
diff --git a/src/test/test_rendcache.c b/src/test/test_rendcache.c
index 9354dd048..9f6cfc4a2 100644
--- a/src/test/test_rendcache.c
+++ b/src/test/test_rendcache.c
@@ -834,7 +834,7 @@ test_rend_cache_failure_entry_free(void *data)
   (void)data;
 
   // Test that it can deal with a NULL argument
-  rend_cache_failure_entry_free(NULL);
+  rend_cache_failure_entry_free_(NULL);
 
  /* done: */
  /*  (void)0; */
@@ -963,7 +963,7 @@ test_rend_cache_entry_free(void *data)
   rend_cache_entry_t *e;
 
   // Handles NULL correctly
-  rend_cache_entry_free(NULL);
+  rend_cache_entry_free_(NULL);
 
   // Handles NULL descriptor correctly
   e = tor_malloc_zero(sizeof(rend_cache_entry_t));
@@ -1135,7 +1135,7 @@ test_rend_cache_failure_intro_entry_free(void *data)
   rend_cache_failure_intro_t *entry;
 
   // Handles a null argument
-  rend_cache_failure_intro_entry_free(NULL);
+  rend_cache_failure_intro_entry_free_(NULL);
 
   // Handles a non-null argument
   entry = rend_cache_failure_intro_entry_new(INTRO_POINT_FAILURE_TIMEOUT);
@@ -1148,7 +1148,7 @@ test_rend_cache_failure_purge(void *data)
   (void)data;
 
   // Handles a null failure cache
-  strmap_free(rend_cache_failure, rend_cache_failure_entry_free_);
+  strmap_free(rend_cache_failure, rend_cache_failure_entry_free_void);
   rend_cache_failure = NULL;
 
   rend_cache_failure_purge();
diff --git a/src/test/test_replay.c b/src/test/test_replay.c
index c379cafa7..d8dcc7370 100644
--- a/src/test/test_replay.c
+++ b/src/test/test_replay.c
@@ -74,7 +74,7 @@ static void
 test_replaycache_free_null(void *arg)
 {
   (void)arg;
-  replaycache_free(NULL);
+  replaycache_free_(NULL);
   /* Assert that we're here without horrible death */
   tt_assert(1);
 
diff --git a/src/test/test_routerset.c b/src/test/test_routerset.c
index 8eb19c3c2..c54132467 100644
--- a/src/test/test_routerset.c
+++ b/src/test/test_routerset.c
@@ -699,7 +699,7 @@ NS(test_main)(void *arg)
 static void
 NS(test_main)(void *arg)
 {
-  const routerset_t *set;
+  routerset_t *set;
   int needs_geoip;
   (void)arg;
 
@@ -709,14 +709,14 @@ NS(test_main)(void *arg)
 
   set = routerset_new();
   needs_geoip = routerset_needs_geoip(set);
-  routerset_free((routerset_t *)set);
+  routerset_free(set);
   tt_int_op(needs_geoip, OP_EQ, 0);
   set = NULL;
 
   set = routerset_new();
   smartlist_add(set->country_names, tor_strndup("xx", 2));
   needs_geoip = routerset_needs_geoip(set);
-  routerset_free((routerset_t *)set);
+  routerset_free(set);
   set = NULL;
   tt_int_op(needs_geoip, OP_NE, 0);
 
@@ -1947,7 +1947,7 @@ NS(test_main)(void *arg)
 
  done:
   tor_free(s);
-  routerset_free((routerset_t *)set);
+  routerset_free(set);
 }
 
 #undef NS_SUBMODULE
@@ -2093,7 +2093,7 @@ NS(test_main)(void *arg)
 
   NS_MOCK(smartlist_free_);
 
-  routerset_free(NULL);
+  routerset_free_(NULL);
 
   tt_int_op(CALLED(smartlist_free_), OP_EQ, 0);
 



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits