diff options
author | George Kadianakis <desnacked@riseup.net> | 2021-07-09 16:54:24 +0300 |
---|---|---|
committer | George Kadianakis <desnacked@riseup.net> | 2021-07-09 17:06:26 +0300 |
commit | 9b464cdc364755fb00b544c31a1e75500a3b84d3 (patch) | |
tree | a3556ac81e97ce54fabc836958d3bb41dea88b10 /src/feature/client | |
parent | a77727cdca35bb272794ee863790d36c8db45caf (diff) | |
download | tor-9b464cdc364755fb00b544c31a1e75500a3b84d3.tar.gz tor-9b464cdc364755fb00b544c31a1e75500a3b84d3.zip |
Add layer2_guard_free()
Diffstat (limited to 'src/feature/client')
-rw-r--r-- | src/feature/client/entrynodes.c | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/src/feature/client/entrynodes.c b/src/feature/client/entrynodes.c index fddb7b8f0f..1e9416c9cf 100644 --- a/src/feature/client/entrynodes.c +++ b/src/feature/client/entrynodes.c @@ -3944,6 +3944,19 @@ typedef struct layer2_guard_t { time_t expire_on_date; } layer2_guard_t; +#define layer2_guard_free(val) \ + FREE_AND_NULL(layer2_guard_t, layer2_guard_free_, (val)) + +static void +layer2_guard_free_(layer2_guard_t *l2) +{ + if (!l2) { + return; + } + + tor_free(l2); +} + /** Global list and routerset of L2 guards. They are both synced and they get * updated periodically. We need both the list and the routerset: we use the * smartlist to keep track of expiration times and the routerset is what we @@ -4029,7 +4042,7 @@ maintain_layer2_guards(void) safe_str_client(hex_str(g->identity, DIGEST_LEN))); // Nickname may be gone from consensus and doesn't matter anyway control_event_guard("None", g->identity, "BAD_L2"); - tor_free(g); + layer2_guard_free(g); SMARTLIST_DEL_CURRENT_KEEPORDER(layer2_guards, g); continue; } @@ -4040,7 +4053,7 @@ maintain_layer2_guards(void) safe_str_client(hex_str(g->identity, DIGEST_LEN))); // Nickname may be gone from consensus and doesn't matter anyway control_event_guard("None", g->identity, "BAD_L2"); - tor_free(g); + layer2_guard_free(g); SMARTLIST_DEL_CURRENT_KEEPORDER(layer2_guards, g); continue; } @@ -4110,7 +4123,7 @@ purge_vanguards_lite(void) /* Go through the list and perform any needed expirations */ SMARTLIST_FOREACH_BEGIN(layer2_guards, layer2_guard_t *, g) { - tor_free(g); + layer2_guard_free(g); } SMARTLIST_FOREACH_END(g); smartlist_clear(layer2_guards); @@ -4158,7 +4171,7 @@ entry_guards_free_all(void) } SMARTLIST_FOREACH_BEGIN(layer2_guards, layer2_guard_t *, g) { - tor_free(g); + layer2_guard_free(g); } SMARTLIST_FOREACH_END(g); smartlist_free(layer2_guards); |