[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [tor/master] Convert the rest of src/common's headers to use FREE_AND_NULL
commit c92ac9f5cbb4440b5f87c7e0dd6bec5147d72405
Author: Nick Mathewson <nickm@xxxxxxxxxxxxxx>
Date: Fri Nov 17 12:27:25 2017 -0500
Convert the rest of src/common's headers to use FREE_AND_NULL
---
src/common/address.c | 6 +++---
src/common/address.h | 13 +++++--------
src/common/aes.c | 4 ++--
src/common/aes.h | 3 ++-
src/common/buffers.c | 2 +-
src/common/buffers.h | 3 ++-
src/common/compat_libevent.c | 4 ++--
src/common/compat_libevent.h | 6 ++++--
src/common/compat_threads.c | 4 ++--
src/common/compat_threads.h | 6 ++++--
src/common/compress.c | 2 +-
src/common/compress.h | 3 ++-
src/common/compress_lzma.c | 2 +-
src/common/compress_lzma.h | 3 ++-
src/common/compress_zlib.c | 2 +-
src/common/compress_zlib.h | 3 ++-
src/common/compress_zstd.c | 2 +-
src/common/compress_zstd.h | 3 ++-
src/common/confline.c | 2 +-
src/common/confline.h | 7 ++++++-
src/common/di_ops.c | 2 +-
src/common/di_ops.h | 7 ++++++-
src/common/handles.h | 4 ++--
src/common/log.c | 6 ++++--
src/common/memarea.c | 2 +-
src/common/memarea.h | 7 ++++++-
src/common/procmon.c | 2 +-
src/common/procmon.h | 4 +++-
src/common/storagedir.c | 2 +-
src/common/storagedir.h | 4 +++-
src/common/timers.c | 2 +-
src/common/timers.h | 3 ++-
src/common/util.c | 2 +-
src/common/util.h | 4 +++-
src/or/channel.h | 2 ++
src/or/conscache.h | 2 ++
src/or/entrynodes.h | 3 +++
src/or/policies.c | 4 ++--
src/test/test-timers.c | 2 +-
src/test/test_address.c | 16 ++++++++--------
src/test/test_handles.c | 2 ++
src/test/test_policy.c | 8 ++++----
42 files changed, 105 insertions(+), 65 deletions(-)
diff --git a/src/common/address.c b/src/common/address.c
index dbe129be5..0c0ba782a 100644
--- a/src/common/address.c
+++ b/src/common/address.c
@@ -1759,14 +1759,14 @@ get_interface_address6,(int severity, sa_family_t family, tor_addr_t *addr))
break;
} SMARTLIST_FOREACH_END(a);
- free_interface_address6_list(addrs);
+ interface_address6_list_free(addrs);
return rv;
}
/** Free a smartlist of IP addresses returned by get_interface_address6_list.
*/
void
-free_interface_address6_list(smartlist_t *addrs)
+interface_address6_list_free_(smartlist_t *addrs)
{
if (addrs != NULL) {
SMARTLIST_FOREACH(addrs, tor_addr_t *, a, tor_free(a));
@@ -1781,7 +1781,7 @@ free_interface_address6_list(smartlist_t *addrs)
* An empty smartlist means that there are no addresses of the selected type
* matching these criteria.
* Returns NULL on failure.
- * Use free_interface_address6_list to free the returned list.
+ * Use interface_address6_list_free to free the returned list.
*/
MOCK_IMPL(smartlist_t *,
get_interface_address6_list,(int severity,
diff --git a/src/common/address.h b/src/common/address.h
index c7f693575..84d136d67 100644
--- a/src/common/address.h
+++ b/src/common/address.h
@@ -206,7 +206,9 @@ const char * fmt_addr32(uint32_t addr);
MOCK_DECL(int,get_interface_address6,(int severity, sa_family_t family,
tor_addr_t *addr));
-void free_interface_address6_list(smartlist_t * addrs);
+void interface_address6_list_free_(smartlist_t * addrs);// XXXX
+#define interface_address6_list_free(addrs) \
+ FREE_AND_NULL(interface_address6_list, (addrs))
MOCK_DECL(smartlist_t *,get_interface_address6_list,(int severity,
sa_family_t family,
int include_internal));
@@ -321,13 +323,8 @@ int addr_mask_get_bits(uint32_t mask);
int tor_inet_ntoa(const struct in_addr *in, char *buf, size_t buf_len);
char *tor_dup_ip(uint32_t addr) ATTR_MALLOC;
MOCK_DECL(int,get_interface_address,(int severity, uint32_t *addr));
-/** Free a smartlist of IP addresses returned by get_interface_address_list.
- */
-static inline void
-free_interface_address_list(smartlist_t *addrs)
-{
- free_interface_address6_list(addrs);
-}
+#define interface_address_list_free(lst)\
+ interface_address6_list_free(lst)
/** Return a smartlist of the IPv4 addresses of all interfaces on the server.
* Excludes loopback and multicast addresses. Only includes internal addresses
* if include_internal is true. (Note that a relay behind NAT may use an
diff --git a/src/common/aes.c b/src/common/aes.c
index df4368fdb..9b5b0197e 100644
--- a/src/common/aes.c
+++ b/src/common/aes.c
@@ -110,7 +110,7 @@ aes_new_cipher(const uint8_t *key, const uint8_t *iv, int key_bits)
return (aes_cnt_cipher_t *) cipher;
}
void
-aes_cipher_free(aes_cnt_cipher_t *cipher_)
+aes_cipher_free_(aes_cnt_cipher_t *cipher_)
{
if (!cipher_)
return;
@@ -324,7 +324,7 @@ aes_set_key(aes_cnt_cipher_t *cipher, const uint8_t *key, int key_bits)
/** Release storage held by <b>cipher</b>
*/
void
-aes_cipher_free(aes_cnt_cipher_t *cipher)
+aes_cipher_free_(aes_cnt_cipher_t *cipher)
{
if (!cipher)
return;
diff --git a/src/common/aes.h b/src/common/aes.h
index 1e400a56e..4874f728d 100644
--- a/src/common/aes.h
+++ b/src/common/aes.h
@@ -17,7 +17,8 @@ typedef struct aes_cnt_cipher aes_cnt_cipher_t;
aes_cnt_cipher_t* aes_new_cipher(const uint8_t *key, const uint8_t *iv,
int key_bits);
-void aes_cipher_free(aes_cnt_cipher_t *cipher);
+void aes_cipher_free_(aes_cnt_cipher_t *cipher);
+#define aes_cipher_free(cipher) FREE_AND_NULL(aes_cipher, (cipher))
void aes_crypt_inplace(aes_cnt_cipher_t *cipher, char *data, size_t len);
int evaluate_evp_for_aes(int force_value);
diff --git a/src/common/buffers.c b/src/common/buffers.c
index a21cf2ab5..fad575ccc 100644
--- a/src/common/buffers.c
+++ b/src/common/buffers.c
@@ -409,7 +409,7 @@ buf_slack(const buf_t *buf)
/** Release storage held by <b>buf</b>. */
void
-buf_free(buf_t *buf)
+buf_free_(buf_t *buf)
{
if (!buf)
return;
diff --git a/src/common/buffers.h b/src/common/buffers.h
index dd96ddcb6..34e9711b2 100644
--- a/src/common/buffers.h
+++ b/src/common/buffers.h
@@ -24,7 +24,8 @@ struct tor_compress_state_t;
buf_t *buf_new(void);
buf_t *buf_new_with_capacity(size_t size);
size_t buf_get_default_chunk_size(const buf_t *buf);
-void buf_free(buf_t *buf);
+void buf_free_(buf_t *buf);
+#define buf_free(b) FREE_AND_NULL(buf, (b))
void buf_clear(buf_t *buf);
buf_t *buf_copy(const buf_t *buf);
diff --git a/src/common/compat_libevent.c b/src/common/compat_libevent.c
index 1c3a1b9f3..10489bf29 100644
--- a/src/common/compat_libevent.c
+++ b/src/common/compat_libevent.c
@@ -69,7 +69,7 @@ suppress_libevent_log_msg(const char *msg)
/* Wrapper for event_free() that tolerates tor_event_free(NULL) */
void
-tor_event_free(struct event *ev)
+tor_event_free_(struct event *ev)
{
if (ev == NULL)
return;
@@ -213,7 +213,7 @@ periodic_timer_new(struct event_base *base,
/** Stop and free a periodic timer */
void
-periodic_timer_free(periodic_timer_t *timer)
+periodic_timer_free_(periodic_timer_t *timer)
{
if (!timer)
return;
diff --git a/src/common/compat_libevent.h b/src/common/compat_libevent.h
index 3d8672fc6..65807315c 100644
--- a/src/common/compat_libevent.h
+++ b/src/common/compat_libevent.h
@@ -19,7 +19,8 @@ void suppress_libevent_log_msg(const char *msg);
evdns_add_server_port_with_base(tor_libevent_get_base(), \
(sock),(tcp),(cb),(data));
-void tor_event_free(struct event *ev);
+void tor_event_free_(struct event *ev);
+#define tor_event_free(ev) FREE_AND_NULL(tor_event, (ev))
typedef struct periodic_timer_t periodic_timer_t;
@@ -27,7 +28,8 @@ periodic_timer_t *periodic_timer_new(struct event_base *base,
const struct timeval *tv,
void (*cb)(periodic_timer_t *timer, void *data),
void *data);
-void periodic_timer_free(periodic_timer_t *);
+void periodic_timer_free_(periodic_timer_t *);
+#define periodic_timer_free(t) FREE_AND_NULL(periodic_timer, (t))
#define tor_event_base_loopexit event_base_loopexit
#define tor_event_base_loopbreak event_base_loopbreak
diff --git a/src/common/compat_threads.c b/src/common/compat_threads.c
index 208d3138d..09aafedb2 100644
--- a/src/common/compat_threads.c
+++ b/src/common/compat_threads.c
@@ -48,7 +48,7 @@ tor_mutex_new_nonrecursive(void)
}
/** Release all storage and system resources held by <b>m</b>. */
void
-tor_mutex_free(tor_mutex_t *m)
+tor_mutex_free_(tor_mutex_t *m)
{
if (!m)
return;
@@ -68,7 +68,7 @@ tor_cond_new(void)
/** Free all storage held in <b>c</b>. */
void
-tor_cond_free(tor_cond_t *c)
+tor_cond_free_(tor_cond_t *c)
{
if (!c)
return;
diff --git a/src/common/compat_threads.h b/src/common/compat_threads.h
index 42f14eab2..26e291ae6 100644
--- a/src/common/compat_threads.h
+++ b/src/common/compat_threads.h
@@ -50,7 +50,8 @@ void tor_mutex_init(tor_mutex_t *m);
void tor_mutex_init_nonrecursive(tor_mutex_t *m);
void tor_mutex_acquire(tor_mutex_t *m);
void tor_mutex_release(tor_mutex_t *m);
-void tor_mutex_free(tor_mutex_t *m);
+void tor_mutex_free_(tor_mutex_t *m);
+#define tor_mutex_free(m) FREE_AND_NULL(tor_mutex, (m))
void tor_mutex_uninit(tor_mutex_t *m);
unsigned long tor_get_thread_id(void);
void tor_threads_init(void);
@@ -77,7 +78,8 @@ typedef struct tor_cond_t {
} tor_cond_t;
tor_cond_t *tor_cond_new(void);
-void tor_cond_free(tor_cond_t *cond);
+void tor_cond_free_(tor_cond_t *cond);
+#define tor_cond_free(c) FREE_AND_NULL(tor_cond, (c))
int tor_cond_init(tor_cond_t *cond);
void tor_cond_uninit(tor_cond_t *cond);
int tor_cond_wait(tor_cond_t *cond, tor_mutex_t *mutex,
diff --git a/src/common/compress.c b/src/common/compress.c
index bc12a58ad..47c93cf6a 100644
--- a/src/common/compress.c
+++ b/src/common/compress.c
@@ -598,7 +598,7 @@ tor_compress_process(tor_compress_state_t *state,
/** Deallocate <b>state</b>. */
void
-tor_compress_free(tor_compress_state_t *state)
+tor_compress_free_(tor_compress_state_t *state)
{
if (state == NULL)
return;
diff --git a/src/common/compress.h b/src/common/compress.h
index 23a981747..eee4a315d 100644
--- a/src/common/compress.h
+++ b/src/common/compress.h
@@ -80,7 +80,8 @@ tor_compress_output_t tor_compress_process(tor_compress_state_t *state,
char **out, size_t *out_len,
const char **in, size_t *in_len,
int finish);
-void tor_compress_free(tor_compress_state_t *state);
+void tor_compress_free_(tor_compress_state_t *state);
+#define tor_compress_free(st) FREE_AND_NULL(tor_compress, (st))
size_t tor_compress_state_size(const tor_compress_state_t *state);
diff --git a/src/common/compress_lzma.c b/src/common/compress_lzma.c
index 6426ede4f..051c59ba2 100644
--- a/src/common/compress_lzma.c
+++ b/src/common/compress_lzma.c
@@ -323,7 +323,7 @@ tor_lzma_compress_process(tor_lzma_compress_state_t *state,
/** Deallocate <b>state</b>. */
void
-tor_lzma_compress_free(tor_lzma_compress_state_t *state)
+tor_lzma_compress_free_(tor_lzma_compress_state_t *state)
{
if (state == NULL)
return;
diff --git a/src/common/compress_lzma.h b/src/common/compress_lzma.h
index 7639d98a7..1e92fd660 100644
--- a/src/common/compress_lzma.h
+++ b/src/common/compress_lzma.h
@@ -31,7 +31,8 @@ tor_lzma_compress_process(tor_lzma_compress_state_t *state,
const char **in, size_t *in_len,
int finish);
-void tor_lzma_compress_free(tor_lzma_compress_state_t *state);
+void tor_lzma_compress_free_(tor_lzma_compress_state_t *state);
+#define tor_lzma_compress_free(st) FREE_AND_NULL(tor_lzma_compress, (st))
size_t tor_lzma_compress_state_size(const tor_lzma_compress_state_t *state);
diff --git a/src/common/compress_zlib.c b/src/common/compress_zlib.c
index 284542e88..23d71d27b 100644
--- a/src/common/compress_zlib.c
+++ b/src/common/compress_zlib.c
@@ -265,7 +265,7 @@ tor_zlib_compress_process(tor_zlib_compress_state_t *state,
/** Deallocate <b>state</b>. */
void
-tor_zlib_compress_free(tor_zlib_compress_state_t *state)
+tor_zlib_compress_free_(tor_zlib_compress_state_t *state)
{
if (state == NULL)
return;
diff --git a/src/common/compress_zlib.h b/src/common/compress_zlib.h
index 8ace467bf..3377e0e8d 100644
--- a/src/common/compress_zlib.h
+++ b/src/common/compress_zlib.h
@@ -31,7 +31,8 @@ tor_zlib_compress_process(tor_zlib_compress_state_t *state,
const char **in, size_t *in_len,
int finish);
-void tor_zlib_compress_free(tor_zlib_compress_state_t *state);
+void tor_zlib_compress_free_(tor_zlib_compress_state_t *state);
+#define tor_zlib_compress_free(st) FREE_AND_NULL(tor_zlib_compress, (st))
size_t tor_zlib_compress_state_size(const tor_zlib_compress_state_t *state);
diff --git a/src/common/compress_zstd.c b/src/common/compress_zstd.c
index c1cdaf17a..0db87d61b 100644
--- a/src/common/compress_zstd.c
+++ b/src/common/compress_zstd.c
@@ -399,7 +399,7 @@ tor_zstd_compress_process(tor_zstd_compress_state_t *state,
/** Deallocate <b>state</b>. */
void
-tor_zstd_compress_free(tor_zstd_compress_state_t *state)
+tor_zstd_compress_free_(tor_zstd_compress_state_t *state)
{
if (state == NULL)
return;
diff --git a/src/common/compress_zstd.h b/src/common/compress_zstd.h
index 02466010f..9f67a9c58 100644
--- a/src/common/compress_zstd.h
+++ b/src/common/compress_zstd.h
@@ -31,7 +31,8 @@ tor_zstd_compress_process(tor_zstd_compress_state_t *state,
const char **in, size_t *in_len,
int finish);
-void tor_zstd_compress_free(tor_zstd_compress_state_t *state);
+void tor_zstd_compress_free_(tor_zstd_compress_state_t *state);
+#define tor_zstd_compress_free(st) FREE_AND_NULL(tor_zstd_compress, (st))
size_t tor_zstd_compress_state_size(const tor_zstd_compress_state_t *state);
diff --git a/src/common/confline.c b/src/common/confline.c
index 781ad2a12..bf613ab74 100644
--- a/src/common/confline.c
+++ b/src/common/confline.c
@@ -330,7 +330,7 @@ config_process_include(const char *path, int recursion_level, int extended,
* Free all the configuration lines on the linked list <b>front</b>.
*/
void
-config_free_lines(config_line_t *front)
+config_free_lines_(config_line_t *front)
{
config_line_t *tmp;
diff --git a/src/common/confline.h b/src/common/confline.h
index feeb9f249..772a9bbbd 100644
--- a/src/common/confline.h
+++ b/src/common/confline.h
@@ -48,7 +48,12 @@ int config_get_lines(const char *string, config_line_t **result, int extended);
int config_get_lines_include(const char *string, config_line_t **result,
int extended, int *has_include,
smartlist_t *opened_lst);
-void config_free_lines(config_line_t *front);
+void config_free_lines_(config_line_t *front);
+#define config_free_lines(front) \
+ do { \
+ config_free_lines_(front); \
+ (front) = NULL; \
+ } while (0)
const char *parse_config_line_from_str_verbose(const char *line,
char **key_out, char **value_out,
const char **err_out);
diff --git a/src/common/di_ops.c b/src/common/di_ops.c
index 7c0b4e763..90e9357c8 100644
--- a/src/common/di_ops.c
+++ b/src/common/di_ops.c
@@ -148,7 +148,7 @@ struct di_digest256_map_t {
/** Release all storage held in <b>map</b>, calling free_fn on each value
* as we go. */
void
-dimap_free(di_digest256_map_t *map, dimap_free_fn free_fn)
+dimap_free_(di_digest256_map_t *map, dimap_free_fn free_fn)
{
while (map) {
di_digest256_map_t *victim = map;
diff --git a/src/common/di_ops.h b/src/common/di_ops.h
index e79973ba5..67d9c9f0d 100644
--- a/src/common/di_ops.h
+++ b/src/common/di_ops.h
@@ -37,7 +37,12 @@ int safe_mem_is_zero(const void *mem, size_t sz);
typedef struct di_digest256_map_t di_digest256_map_t;
typedef void (*dimap_free_fn)(void *);
-void dimap_free(di_digest256_map_t *map, dimap_free_fn free_fn);
+void dimap_free_(di_digest256_map_t *map, dimap_free_fn free_fn);
+#define dimap_free(map, free_fn) \
+ do { \
+ dimap_free_((map), (free_fn)); \
+ (map) = NULL; \
+ } while (0)
void dimap_add_entry(di_digest256_map_t **map,
const uint8_t *key, void *val);
void *dimap_search(const di_digest256_map_t *map, const uint8_t *key,
diff --git a/src/common/handles.h b/src/common/handles.h
index a610753a1..aef8cd89e 100644
--- a/src/common/handles.h
+++ b/src/common/handles.h
@@ -59,7 +59,7 @@
#define HANDLE_DECL(name, structname, linkage) \
typedef struct name ## _handle_t name ## _handle_t; \
linkage name ## _handle_t *name ## _handle_new(struct structname *object); \
- linkage void name ## _handle_free(name ## _handle_t *); \
+ linkage void name ## _handle_free_(name ## _handle_t *); \
linkage struct structname *name ## _handle_get(name ## _handle_t *); \
linkage void name ## _handles_clear(struct structname *object);
@@ -113,7 +113,7 @@
} \
\
linkage void \
- name ## _handle_free(struct name ## _handle_t *ref) \
+ name ## _handle_free_(struct name ## _handle_t *ref) \
{ \
if (! ref) return; \
name ## _handle_head_t *head = ref->head; \
diff --git a/src/common/log.c b/src/common/log.c
index 0becb5ce0..83098b101 100644
--- a/src/common/log.c
+++ b/src/common/log.c
@@ -63,7 +63,9 @@ typedef struct logfile_t {
* log for each log domain? */
} logfile_t;
-static void log_free(logfile_t *victim);
+static void log_free_(logfile_t *victim);
+#define log_free(lg) \
+ FREE_AND_NULL(log, (lg))
/** Helper: map a log severity to descriptive string. */
static inline const char *
@@ -721,7 +723,7 @@ log_fn_ratelim_(ratelim_t *ratelim, int severity, log_domain_mask_t domain,
/** Free all storage held by <b>victim</b>. */
static void
-log_free(logfile_t *victim)
+log_free_(logfile_t *victim)
{
if (!victim)
return;
diff --git a/src/common/memarea.c b/src/common/memarea.c
index b059987e0..fa7b69a43 100644
--- a/src/common/memarea.c
+++ b/src/common/memarea.c
@@ -153,7 +153,7 @@ memarea_new(void)
/** Free <b>area</b>, invalidating all pointers returned from memarea_alloc()
* and friends for this area */
void
-memarea_drop_all(memarea_t *area)
+memarea_drop_all_(memarea_t *area)
{
memarea_chunk_t *chunk, *next;
for (chunk = area->first; chunk; chunk = next) {
diff --git a/src/common/memarea.h b/src/common/memarea.h
index c3d954e1c..5207e8a5b 100644
--- a/src/common/memarea.h
+++ b/src/common/memarea.h
@@ -8,7 +8,12 @@
typedef struct memarea_t memarea_t;
memarea_t *memarea_new(void);
-void memarea_drop_all(memarea_t *area);
+void memarea_drop_all_(memarea_t *area);
+#define memarea_drop_all(area) \
+ do { \
+ memarea_drop_all_(area); \
+ (area) = NULL; \
+ } while (0)
void memarea_clear(memarea_t *area);
int memarea_owns_ptr(const memarea_t *area, const void *ptr);
void *memarea_alloc(memarea_t *area, size_t sz);
diff --git a/src/common/procmon.c b/src/common/procmon.c
index 26c11823e..abcbbeaa2 100644
--- a/src/common/procmon.c
+++ b/src/common/procmon.c
@@ -325,7 +325,7 @@ tor_process_monitor_poll_cb(evutil_socket_t unused1, short unused2,
/** Free the process-termination monitor <b>procmon</b>. */
void
-tor_process_monitor_free(tor_process_monitor_t *procmon)
+tor_process_monitor_free_(tor_process_monitor_t *procmon)
{
if (procmon == NULL)
return;
diff --git a/src/common/procmon.h b/src/common/procmon.h
index 10ead11ba..691a5a124 100644
--- a/src/common/procmon.h
+++ b/src/common/procmon.h
@@ -27,7 +27,9 @@ tor_process_monitor_t *tor_process_monitor_new(struct event_base *base,
tor_procmon_callback_t cb,
void *cb_arg,
const char **msg);
-void tor_process_monitor_free(tor_process_monitor_t *procmon);
+void tor_process_monitor_free_(tor_process_monitor_t *procmon);
+#define tor_process_monitor_free(procmon) \
+ FREE_AND_NULL(tor_process_monitor, (procmon))
#endif /* !defined(TOR_PROCMON_H) */
diff --git a/src/common/storagedir.c b/src/common/storagedir.c
index 31933f64c..cd0c78706 100644
--- a/src/common/storagedir.c
+++ b/src/common/storagedir.c
@@ -59,7 +59,7 @@ storage_dir_new(const char *dirname, int max_files)
* Drop all in-RAM storage for <b>d</b>. Does not delete any files.
*/
void
-storage_dir_free(storage_dir_t *d)
+storage_dir_free_(storage_dir_t *d)
{
if (d == NULL)
return;
diff --git a/src/common/storagedir.h b/src/common/storagedir.h
index 3de0afc36..8408ab50d 100644
--- a/src/common/storagedir.h
+++ b/src/common/storagedir.h
@@ -9,7 +9,9 @@ struct config_line_t;
struct sandbox_cfg_elem;
storage_dir_t * storage_dir_new(const char *dirname, int n_files);
-void storage_dir_free(storage_dir_t *d);
+void storage_dir_free_(storage_dir_t *d);
+#define storage_dir_free(d) FREE_AND_NULL(storage_dir, (d))
+
int storage_dir_register_with_sandbox(storage_dir_t *d,
struct sandbox_cfg_elem **cfg);
const smartlist_t *storage_dir_list(storage_dir_t *d);
diff --git a/src/common/timers.c b/src/common/timers.c
index c8e09414f..93cde7de5 100644
--- a/src/common/timers.c
+++ b/src/common/timers.c
@@ -245,7 +245,7 @@ timer_new(timer_cb_fn_t cb, void *arg)
* scheduled.
*/
void
-timer_free(tor_timer_t *t)
+timer_free_(tor_timer_t *t)
{
if (! t)
return;
diff --git a/src/common/timers.h b/src/common/timers.h
index d4d4fb00a..6c9594d31 100644
--- a/src/common/timers.h
+++ b/src/common/timers.h
@@ -17,7 +17,8 @@ void timer_get_cb(const tor_timer_t *t,
timer_cb_fn_t *cb_out, void **arg_out);
void timer_schedule(tor_timer_t *t, const struct timeval *delay);
void timer_disable(tor_timer_t *t);
-void timer_free(tor_timer_t *t);
+void timer_free_(tor_timer_t *t);
+#define timer_free(t) FREE_AND_NULL(timer, (t))
void timers_initialize(void);
void timers_shutdown(void);
diff --git a/src/common/util.c b/src/common/util.c
index 7dc5e8144..67e97811c 100644
--- a/src/common/util.c
+++ b/src/common/util.c
@@ -4713,7 +4713,7 @@ environment_variable_names_equal(const char *s1, const char *s2)
/** Free <b>env</b> (assuming it was produced by
* process_environment_make). */
void
-process_environment_free(process_environment_t *env)
+process_environment_free_(process_environment_t *env)
{
if (env == NULL) return;
diff --git a/src/common/util.h b/src/common/util.h
index e11265a5d..c5bd3f0bd 100644
--- a/src/common/util.h
+++ b/src/common/util.h
@@ -431,7 +431,9 @@ struct process_environment_t {
};
process_environment_t *process_environment_make(struct smartlist_t *env_vars);
-void process_environment_free(process_environment_t *env);
+void process_environment_free_(process_environment_t *env);
+#define process_environment_free(env) \
+ FREE_AND_NULL(process_environment, (env))
struct smartlist_t *get_current_process_environment_variables(void);
diff --git a/src/or/channel.h b/src/or/channel.h
index 32336fe1d..e23d70791 100644
--- a/src/or/channel.h
+++ b/src/or/channel.h
@@ -719,6 +719,8 @@ int packed_cell_is_destroy(channel_t *chan,
/* Declare the handle helpers */
HANDLE_DECL(channel, channel_s,)
+#define channel_handle_free(h) \
+ FREE_AND_NULL(channel_handle, (h))
#endif /* !defined(TOR_CHANNEL_H) */
diff --git a/src/or/conscache.h b/src/or/conscache.h
index 3c89dedf4..e4f308fa4 100644
--- a/src/or/conscache.h
+++ b/src/or/conscache.h
@@ -10,6 +10,8 @@ typedef struct consensus_cache_entry_t consensus_cache_entry_t;
typedef struct consensus_cache_t consensus_cache_t;
HANDLE_DECL(consensus_cache_entry, consensus_cache_entry_t, )
+#define consensus_cache_entry_handle_free(h) \
+ 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);
diff --git a/src/or/entrynodes.h b/src/or/entrynodes.h
index 3ca966bc7..d7f4967a0 100644
--- a/src/or/entrynodes.h
+++ b/src/or/entrynodes.h
@@ -476,6 +476,9 @@ STATIC double get_meaningful_restriction_threshold(void);
STATIC double get_extreme_restriction_threshold(void);
HANDLE_DECL(entry_guard, entry_guard_t, STATIC)
+#define entry_guard_handle_free(h) \
+ FREE_AND_NULL(entry_guard_handle, (h))
+
STATIC guard_selection_type_t guard_selection_infer_type(
guard_selection_type_t type_in,
const char *name);
diff --git a/src/or/policies.c b/src/or/policies.c
index 1f8013071..2e584095d 100644
--- a/src/or/policies.c
+++ b/src/or/policies.c
@@ -1792,14 +1792,14 @@ policies_parse_exit_policy_reject_private(
/* Reject public IPv4 addresses on any interface */
public_addresses = get_interface_address6_list(LOG_INFO, AF_INET, 0);
addr_policy_append_reject_addr_list_filter(dest, public_addresses, 1, 0);
- free_interface_address6_list(public_addresses);
+ interface_address6_list_free(public_addresses);
/* Don't look for IPv6 addresses if we're configured as IPv4-only */
if (ipv6_exit) {
/* Reject public IPv6 addresses on any interface */
public_addresses = get_interface_address6_list(LOG_INFO, AF_INET6, 0);
addr_policy_append_reject_addr_list_filter(dest, public_addresses, 0, 1);
- free_interface_address6_list(public_addresses);
+ interface_address6_list_free(public_addresses);
}
}
diff --git a/src/test/test-timers.c b/src/test/test-timers.c
index 99715f433..a0b5b535c 100644
--- a/src/test/test-timers.c
+++ b/src/test/test-timers.c
@@ -133,7 +133,7 @@ main(int argc, char **argv)
ret = 0;
}
- timer_free(NULL);
+ timer_free_(NULL);
for (i = 0; i < N_TIMERS; ++i) {
timer_free(timers[i]);
diff --git a/src/test/test_address.c b/src/test/test_address.c
index f36ff6998..9c88d37a4 100644
--- a/src/test/test_address.c
+++ b/src/test/test_address.c
@@ -763,7 +763,7 @@ test_address_get_if_addrs_list_internal(void *arg)
tt_assert(!smartlist_contains_ipv6_tor_addr(results));
done:
- free_interface_address_list(results);
+ interface_address_list_free(results);
return;
}
@@ -792,7 +792,7 @@ test_address_get_if_addrs_list_no_internal(void *arg)
tt_assert(!smartlist_contains_ipv6_tor_addr(results));
done:
- free_interface_address_list(results);
+ interface_address_list_free(results);
return;
}
@@ -834,7 +834,7 @@ test_address_get_if_addrs6_list_internal(void *arg)
}
done:
- free_interface_address6_list(results);
+ interface_address6_list_free(results);
teardown_capture_of_logs();
return;
}
@@ -878,7 +878,7 @@ test_address_get_if_addrs6_list_no_internal(void *arg)
done:
teardown_capture_of_logs();
- free_interface_address6_list(results);
+ interface_address6_list_free(results);
return;
}
@@ -943,8 +943,8 @@ test_address_get_if_addrs_internal_fail(void *arg)
done:
UNMOCK(get_interface_addresses_raw);
UNMOCK(get_interface_address6_via_udp_socket_hack);
- free_interface_address6_list(results1);
- free_interface_address6_list(results2);
+ interface_address6_list_free(results1);
+ interface_address6_list_free(results2);
return;
}
@@ -971,8 +971,8 @@ test_address_get_if_addrs_no_internal_fail(void *arg)
done:
UNMOCK(get_interface_addresses_raw);
UNMOCK(get_interface_address6_via_udp_socket_hack);
- free_interface_address6_list(results1);
- free_interface_address6_list(results2);
+ interface_address6_list_free(results1);
+ interface_address6_list_free(results2);
return;
}
diff --git a/src/test/test_handles.c b/src/test/test_handles.c
index 7ddee6e37..03ae0883c 100644
--- a/src/test/test_handles.c
+++ b/src/test/test_handles.c
@@ -13,6 +13,8 @@ typedef struct demo_t {
} demo_t;
HANDLE_DECL(demo, demo_t, static)
+#define demo_handle_free(h) \
+ FREE_AND_NULL(demo_handle, (h))
HANDLE_IMPL(demo, demo_t, static)
static demo_t *
diff --git a/src/test/test_policy.c b/src/test/test_policy.c
index 83dca2d43..f8aa8ac40 100644
--- a/src/test/test_policy.c
+++ b/src/test/test_policy.c
@@ -1318,7 +1318,7 @@ mock_get_interface_address6_list(int severity,
return clone_list;
done:
- free_interface_address6_list(clone_list);
+ interface_address6_list_free(clone_list);
return NULL;
}
@@ -1393,11 +1393,11 @@ test_policies_reject_interface_address(void *arg)
done:
addr_policy_list_free(policy);
- free_interface_address6_list(public_ipv4_addrs);
- free_interface_address6_list(public_ipv6_addrs);
+ interface_address6_list_free(public_ipv4_addrs);
+ interface_address6_list_free(public_ipv6_addrs);
UNMOCK(get_interface_address6_list);
- /* we don't use free_interface_address6_list on these lists because their
+ /* we don't use interface_address6_list_free on these lists because their
* address pointers are stack-based */
smartlist_free(mock_ipv4_addrs);
smartlist_free(mock_ipv6_addrs);
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits