summaryrefslogtreecommitdiff
path: root/src/resolve
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2015-12-09 17:38:48 +0100
committerLennart Poettering <lennart@poettering.net>2015-12-10 11:28:02 +0100
commitd42800f18e78573c81e7caa134fb9311c5a32b5f (patch)
tree51bc901ee0585b9856e25d0aa411ba7615a54553 /src/resolve
parent7bcffc2efa266823d9c2da1d8536e7f9c6e70a32 (diff)
resolved: split out logic to flush DnsAnswer objects
Let's simplify things, by making this a function call of its own.
Diffstat (limited to 'src/resolve')
-rw-r--r--src/resolve/resolved-dns-answer.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/resolve/resolved-dns-answer.c b/src/resolve/resolved-dns-answer.c
index 4db67f7278..14cba39ad2 100644
--- a/src/resolve/resolved-dns-answer.c
+++ b/src/resolve/resolved-dns-answer.c
@@ -46,6 +46,18 @@ DnsAnswer *dns_answer_ref(DnsAnswer *a) {
return a;
}
+static void dns_answer_flush(DnsAnswer *a) {
+ DnsResourceRecord *rr;
+
+ if (!a)
+ return;
+
+ DNS_ANSWER_FOREACH(rr, a)
+ dns_resource_record_unref(rr);
+
+ a->n_rrs = 0;
+}
+
DnsAnswer *dns_answer_unref(DnsAnswer *a) {
if (!a)
return NULL;
@@ -53,11 +65,7 @@ DnsAnswer *dns_answer_unref(DnsAnswer *a) {
assert(a->n_ref > 0);
if (a->n_ref == 1) {
- unsigned i;
-
- for (i = 0; i < a->n_rrs; i++)
- dns_resource_record_unref(a->items[i].rr);
-
+ dns_answer_flush(a);
free(a);
} else
a->n_ref--;