diff options
author | Nick Mathewson <nickm@torproject.org> | 2017-12-08 10:21:12 -0500 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2017-12-08 14:47:19 -0500 |
commit | fa0d24286b1dac3959c338f6b76fc15dbe1559e5 (patch) | |
tree | 5ec27cfa8b633cc6729bbb7da9eface2541ccb28 /src/common | |
parent | 17dcce3fe11bfea9c7c46d2b9fd5baeb63ebe1e2 (diff) | |
download | tor-fa0d24286b1dac3959c338f6b76fc15dbe1559e5.tar.gz tor-fa0d24286b1dac3959c338f6b76fc15dbe1559e5.zip |
Convert remaining function (mostly static) to new free style
Diffstat (limited to 'src/common')
-rw-r--r-- | src/common/compat.c | 5 | ||||
-rw-r--r-- | src/common/container.c | 13 | ||||
-rw-r--r-- | src/common/log.c | 5 | ||||
-rw-r--r-- | src/common/sandbox.c | 6 | ||||
-rw-r--r-- | src/common/workqueue.c | 5 |
5 files changed, 27 insertions, 7 deletions
diff --git a/src/common/compat.c b/src/common/compat.c index 38693b21fe..b4bd6eba06 100644 --- a/src/common/compat.c +++ b/src/common/compat.c @@ -1905,9 +1905,12 @@ tor_passwd_dup(const struct passwd *pw) return new_pw; } +#define tor_passwd_free(pw) \ + FREE_AND_NULL(struct passwd, tor_passwd_free_, (pw)) + /** Helper: free one of our cached 'struct passwd' values. */ static void -tor_passwd_free(struct passwd *pw) +tor_passwd_free_(struct passwd *pw) { if (!pw) return; diff --git a/src/common/container.c b/src/common/container.c index a6e3c11f35..54b0b2028f 100644 --- a/src/common/container.c +++ b/src/common/container.c @@ -1163,19 +1163,26 @@ HT_GENERATE2(digest256map_impl, digest256map_entry_t, node, digest256map_entry_hash, digest256map_entries_eq, 0.6, tor_reallocarray_, tor_free_) +#define strmap_entry_free(ent) \ + FREE_AND_NULL(strmap_entry_t, strmap_entry_free_, (ent)) +#define digestmap_entry_free(ent) \ + FREE_AND_NULL(digestmap_entry_t, digestmap_entry_free_, (ent)) +#define digest256map_entry_free(ent) \ + FREE_AND_NULL(digest256map_entry_t, digest256map_entry_free_, (ent)) + static inline void -strmap_entry_free(strmap_entry_t *ent) +strmap_entry_free_(strmap_entry_t *ent) { tor_free(ent->key); tor_free(ent); } static inline void -digestmap_entry_free(digestmap_entry_t *ent) +digestmap_entry_free_(digestmap_entry_t *ent) { tor_free(ent); } static inline void -digest256map_entry_free(digest256map_entry_t *ent) +digest256map_entry_free_(digest256map_entry_t *ent) { tor_free(ent); } diff --git a/src/common/log.c b/src/common/log.c index 9d4219be1a..80055fda04 100644 --- a/src/common/log.c +++ b/src/common/log.c @@ -387,9 +387,12 @@ pending_log_message_new(int severity, log_domain_mask_t domain, return m; } +#define pending_log_message_free(msg) \ + FREE_AND_NULL(pending_log_message_t, pending_log_message_free_, (msg)) + /** Release all storage held by <b>msg</b>. */ static void -pending_log_message_free(pending_log_message_t *msg) +pending_log_message_free_(pending_log_message_t *msg) { if (!msg) return; diff --git a/src/common/sandbox.c b/src/common/sandbox.c index 8cb78bd28e..31beaa341a 100644 --- a/src/common/sandbox.c +++ b/src/common/sandbox.c @@ -1446,8 +1446,12 @@ cached_getaddrinfo_items_eq(const cached_getaddrinfo_item_t *a, return (a->family == b->family) && 0 == strcmp(a->name, b->name); } +#define cached_getaddrinfo_item_free(item) \ + FREE_AND_NULL(cached_getaddrinfo_item_t, \ + cached_getaddrinfo_item_free_, (item)) + static void -cached_getaddrinfo_item_free(cached_getaddrinfo_item_t *item) +cached_getaddrinfo_item_free_(cached_getaddrinfo_item_t *item) { if (item == NULL) return; diff --git a/src/common/workqueue.c b/src/common/workqueue.c index 42723224d3..ec96959b7d 100644 --- a/src/common/workqueue.c +++ b/src/common/workqueue.c @@ -148,12 +148,15 @@ workqueue_entry_new(workqueue_reply_t (*fn)(void*, void*), return ent; } +#define workqueue_entry_free(ent) \ + FREE_AND_NULL(workqueue_entry_t, workqueue_entry_free_, (ent)) + /** * Release all storage held in <b>ent</b>. Call only when <b>ent</b> is not on * any queue. */ static void -workqueue_entry_free(workqueue_entry_t *ent) +workqueue_entry_free_(workqueue_entry_t *ent) { if (!ent) return; |