From 8301aa0bf145099e55443b8c10d00a62d20e0d29 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Mon, 27 Aug 2018 14:01:46 +0900 Subject: tree-wide: use DEFINE_TRIVIAL_REF_UNREF_FUNC() macro or friends where applicable --- src/resolve/resolved-dns-rr.c | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) (limited to 'src/resolve/resolved-dns-rr.c') diff --git a/src/resolve/resolved-dns-rr.c b/src/resolve/resolved-dns-rr.c index e6d997ed97..67565d267e 100644 --- a/src/resolve/resolved-dns-rr.c +++ b/src/resolve/resolved-dns-rr.c @@ -399,26 +399,8 @@ DnsResourceRecord* dns_resource_record_new_full(uint16_t class, uint16_t type, c return dns_resource_record_new(key); } -DnsResourceRecord* dns_resource_record_ref(DnsResourceRecord *rr) { - if (!rr) - return NULL; - - assert(rr->n_ref > 0); - rr->n_ref++; - - return rr; -} - -DnsResourceRecord* dns_resource_record_unref(DnsResourceRecord *rr) { - if (!rr) - return NULL; - - assert(rr->n_ref > 0); - - if (rr->n_ref > 1) { - rr->n_ref--; - return NULL; - } +static DnsResourceRecord* dns_resource_record_free(DnsResourceRecord *rr) { + assert(rr); if (rr->key) { switch(rr->key->type) { @@ -512,6 +494,8 @@ DnsResourceRecord* dns_resource_record_unref(DnsResourceRecord *rr) { return mfree(rr); } +DEFINE_TRIVIAL_REF_UNREF_FUNC(DnsResourceRecord, dns_resource_record, dns_resource_record_free); + int dns_resource_record_new_reverse(DnsResourceRecord **ret, int family, const union in_addr_union *address, const char *hostname) { _cleanup_(dns_resource_key_unrefp) DnsResourceKey *key = NULL; _cleanup_(dns_resource_record_unrefp) DnsResourceRecord *rr = NULL; -- cgit v1.2.3