diff options
author | Nick Mathewson <nickm@torproject.org> | 2017-11-21 08:29:42 -0500 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2017-12-08 14:47:19 -0500 |
commit | b0cc9856ee560865d2668afbff20e8b77986e4ee (patch) | |
tree | 3411bb448b33a9f256020784e28aa62fe338b14d /src/or | |
parent | c92ac9f5cbb4440b5f87c7e0dd6bec5147d72405 (diff) | |
download | tor-b0cc9856ee560865d2668afbff20e8b77986e4ee.tar.gz tor-b0cc9856ee560865d2668afbff20e8b77986e4ee.zip |
Update free functions into macros: src/or/ part 1
This covers addressmap.h (no change needed) through confparse.h
Diffstat (limited to 'src/or')
-rw-r--r-- | src/or/channel.c | 5 | ||||
-rw-r--r-- | src/or/channel.h | 6 | ||||
-rw-r--r-- | src/or/circuitbuild.c | 2 | ||||
-rw-r--r-- | src/or/circuitbuild.h | 3 | ||||
-rw-r--r-- | src/or/circuitlist.c | 2 | ||||
-rw-r--r-- | src/or/circuitlist.h | 3 | ||||
-rw-r--r-- | src/or/circuitmux.c | 2 | ||||
-rw-r--r-- | src/or/circuitmux.h | 3 | ||||
-rw-r--r-- | src/or/config.c | 2 | ||||
-rw-r--r-- | src/or/config.h | 3 | ||||
-rw-r--r-- | src/or/confparse.c | 2 | ||||
-rw-r--r-- | src/or/confparse.h | 7 |
12 files changed, 26 insertions, 14 deletions
diff --git a/src/or/channel.c b/src/or/channel.c index 0b5a7fde90..a9e081795b 100644 --- a/src/or/channel.c +++ b/src/or/channel.c @@ -1,3 +1,4 @@ + /* * Copyright (c) 2012-2017, The Tor Project, Inc. */ /* See LICENSE for licensing information */ @@ -979,7 +980,7 @@ channel_init_listener(channel_listener_t *chan_l) */ void -channel_free(channel_t *chan) +channel_free_(channel_t *chan) { if (!chan) return; @@ -1034,7 +1035,7 @@ channel_free(channel_t *chan) */ void -channel_listener_free(channel_listener_t *chan_l) +channel_listener_free_(channel_listener_t *chan_l) { if (!chan_l) return; diff --git a/src/or/channel.h b/src/or/channel.h index e23d707915..0ee99dcaff 100644 --- a/src/or/channel.h +++ b/src/or/channel.h @@ -516,8 +516,10 @@ void channel_listener_close_for_error(channel_listener_t *chan_l); void channel_listener_closed(channel_listener_t *chan_l); /* Free a channel */ -void channel_free(channel_t *chan); -void channel_listener_free(channel_listener_t *chan_l); +void channel_free_(channel_t *chan); +#define channel_free(chan) FREE_AND_NULL(channel, (chan)) +void channel_listener_free_(channel_listener_t *chan_l); +#define channel_listener_free(chan_l) FREE_AND_NULL(channel_listener, (chan_l)) /* State/metadata setters */ diff --git a/src/or/circuitbuild.c b/src/or/circuitbuild.c index 7f0bcc4150..2b581396f4 100644 --- a/src/or/circuitbuild.c +++ b/src/or/circuitbuild.c @@ -2729,7 +2729,7 @@ extend_info_from_node(const node_t *node, int for_direct_connect) /** Release storage held by an extend_info_t struct. */ void -extend_info_free(extend_info_t *info) +extend_info_free_(extend_info_t *info) { if (!info) return; diff --git a/src/or/circuitbuild.h b/src/or/circuitbuild.h index b8a651e055..6c3c91f83b 100644 --- a/src/or/circuitbuild.h +++ b/src/or/circuitbuild.h @@ -58,7 +58,8 @@ extend_info_t *extend_info_new(const char *nickname, const tor_addr_t *addr, uint16_t port); extend_info_t *extend_info_from_node(const node_t *r, int for_direct_connect); extend_info_t *extend_info_dup(extend_info_t *info); -void extend_info_free(extend_info_t *info); +void extend_info_free_(extend_info_t *info); +#define extend_info_free(info) FREE_AND_NULL(extend_info, (info)) int extend_info_addr_is_allowed(const tor_addr_t *addr); int extend_info_supports_tap(const extend_info_t* ei); int extend_info_supports_ntor(const extend_info_t* ei); diff --git a/src/or/circuitlist.c b/src/or/circuitlist.c index d37d986f17..0171ed4f13 100644 --- a/src/or/circuitlist.c +++ b/src/or/circuitlist.c @@ -924,7 +924,7 @@ circuit_clear_testing_cell_stats(circuit_t *circ) /** Deallocate space associated with circ. */ STATIC void -circuit_free(circuit_t *circ) +circuit_free_(circuit_t *circ) { circid_t n_circ_id = 0; void *mem; diff --git a/src/or/circuitlist.h b/src/or/circuitlist.h index 5d0da15ca8..ffa250b2c5 100644 --- a/src/or/circuitlist.h +++ b/src/or/circuitlist.h @@ -81,7 +81,8 @@ MOCK_DECL(void, channel_note_destroy_not_pending, smartlist_t *circuit_find_circuits_to_upgrade_from_guard_wait(void); #ifdef CIRCUITLIST_PRIVATE -STATIC void circuit_free(circuit_t *circ); +STATIC void circuit_free_(circuit_t *circ); +#define circuit_free(circ) FREE_AND_NULL(circuit, (circ)) STATIC size_t n_cells_in_circ_queues(const circuit_t *c); STATIC uint32_t circuit_max_queued_data_age(const circuit_t *c, uint32_t now); STATIC uint32_t circuit_max_queued_cell_age(const circuit_t *c, uint32_t now); diff --git a/src/or/circuitmux.c b/src/or/circuitmux.c index f3b8aecb1b..d8408f45fc 100644 --- a/src/or/circuitmux.c +++ b/src/or/circuitmux.c @@ -546,7 +546,7 @@ circuitmux_mark_destroyed_circids_usable(circuitmux_t *cmux, channel_t *chan) */ void -circuitmux_free(circuitmux_t *cmux) +circuitmux_free_(circuitmux_t *cmux) { if (!cmux) return; diff --git a/src/or/circuitmux.h b/src/or/circuitmux.h index 3e7496ea1c..e7f345f678 100644 --- a/src/or/circuitmux.h +++ b/src/or/circuitmux.h @@ -104,7 +104,8 @@ void circuitmux_assert_okay(circuitmux_t *cmux); circuitmux_t * circuitmux_alloc(void); void circuitmux_detach_all_circuits(circuitmux_t *cmux, smartlist_t *detached_out); -void circuitmux_free(circuitmux_t *cmux); +void circuitmux_free_(circuitmux_t *cmux); +#define circuitmux_free(cmux) FREE_AND_NULL(circuitmux, (cmux)) /* Policy control */ void circuitmux_clear_policy(circuitmux_t *cmux); diff --git a/src/or/config.c b/src/or/config.c index fac3a36d10..b32576ccc3 100644 --- a/src/or/config.c +++ b/src/or/config.c @@ -5739,7 +5739,7 @@ validate_transport_socks_arguments(const smartlist_t *args) /** Deallocate a bridge_line_t structure. */ /* private */ void -bridge_line_free(bridge_line_t *bridge_line) +bridge_line_free_(bridge_line_t *bridge_line) { if (!bridge_line) return; diff --git a/src/or/config.h b/src/or/config.h index efdd8c59b0..cc8003fb35 100644 --- a/src/or/config.h +++ b/src/or/config.h @@ -152,7 +152,8 @@ typedef struct bridge_line_t { transport proxy. */ } bridge_line_t; -void bridge_line_free(bridge_line_t *bridge_line); +void bridge_line_free_(bridge_line_t *bridge_line); +#define bridge_line_free(line) FREE_AND_NULL(bridge_line, (line)) bridge_line_t *parse_bridge_line(const char *line); smartlist_t *get_options_from_transport_options_line(const char *line, const char *transport); diff --git a/src/or/confparse.c b/src/or/confparse.c index abae7e33dc..64ed9ee6bb 100644 --- a/src/or/confparse.c +++ b/src/or/confparse.c @@ -863,7 +863,7 @@ config_reset(const config_format_t *fmt, void *options, /** Release storage held by <b>options</b>. */ void -config_free(const config_format_t *fmt, void *options) +config_free_(const config_format_t *fmt, void *options) { int i; diff --git a/src/or/confparse.h b/src/or/confparse.h index 6f0b3b325c..f497f55ac1 100644 --- a/src/or/confparse.h +++ b/src/or/confparse.h @@ -177,7 +177,12 @@ typedef struct config_format_t { #define CAL_WARN_DEPRECATIONS (1u<<2) void *config_new(const config_format_t *fmt); -void config_free(const config_format_t *fmt, void *options); +void config_free_(const config_format_t *fmt, void *options); +#define config_free(fmt, options) do { \ + config_free_((fmt), (options)); \ + (options) = NULL; \ + } while (0) + config_line_t *config_get_assigned_option(const config_format_t *fmt, const void *options, const char *key, int escape_val); |