summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/resolve/resolved-dns-cache.c7
-rw-r--r--src/resolve/resolved-dns-server.c15
-rw-r--r--src/resolve/resolved-link.c6
-rw-r--r--src/resolve/resolved-manager.c4
-rw-r--r--src/shared/prioq.c6
-rw-r--r--src/shared/prioq.h2
6 files changed, 20 insertions, 20 deletions
diff --git a/src/resolve/resolved-dns-cache.c b/src/resolve/resolved-dns-cache.c
index 33ca4d1a45..be52891681 100644
--- a/src/resolve/resolved-dns-cache.c
+++ b/src/resolve/resolved-dns-cache.c
@@ -91,11 +91,8 @@ void dns_cache_flush(DnsCache *c) {
assert(hashmap_size(c->by_key) == 0);
assert(prioq_size(c->by_expiry) == 0);
- hashmap_free(c->by_key);
- c->by_key = NULL;
-
- prioq_free(c->by_expiry);
- c->by_expiry = NULL;
+ c->by_key = hashmap_free(c->by_key);
+ c->by_expiry = prioq_free(c->by_expiry);
}
static void dns_cache_remove(DnsCache *c, DnsResourceKey *key) {
diff --git a/src/resolve/resolved-dns-server.c b/src/resolve/resolved-dns-server.c
index caf06fe450..9a62a63258 100644
--- a/src/resolve/resolved-dns-server.c
+++ b/src/resolve/resolved-dns-server.c
@@ -78,23 +78,24 @@ DnsServer* dns_server_free(DnsServer *s) {
if (!s)
return NULL;
- if (s->manager) {
+ if (s->link) {
if (s->type == DNS_SERVER_LINK)
LIST_REMOVE(servers, s->link->dns_servers, s);
- else if (s->type == DNS_SERVER_SYSTEM)
+
+ if (s->link->current_dns_server == s)
+ link_set_dns_server(s->link, NULL);
+ }
+
+ if (s->manager) {
+ if (s->type == DNS_SERVER_SYSTEM)
LIST_REMOVE(servers, s->manager->dns_servers, s);
else if (s->type == DNS_SERVER_FALLBACK)
LIST_REMOVE(servers, s->manager->fallback_dns_servers, s);
- else
- assert_not_reached("Unknown server type");
if (s->manager->current_dns_server == s)
manager_set_dns_server(s->manager, NULL);
}
- if (s->link && s->link->current_dns_server == s)
- link_set_dns_server(s->link, NULL);
-
free(s);
return NULL;
diff --git a/src/resolve/resolved-link.c b/src/resolve/resolved-link.c
index f94e4bb6f0..27d9129e00 100644
--- a/src/resolve/resolved-link.c
+++ b/src/resolve/resolved-link.c
@@ -68,13 +68,13 @@ Link *link_free(Link *l) {
if (l->manager)
hashmap_remove(l->manager->links, INT_TO_PTR(l->ifindex));
+ while (l->dns_servers)
+ dns_server_free(l->dns_servers);
+
dns_scope_free(l->unicast_scope);
dns_scope_free(l->llmnr_ipv4_scope);
dns_scope_free(l->llmnr_ipv6_scope);
- while (l->dns_servers)
- dns_server_free(l->dns_servers);
-
free(l);
return NULL;
}
diff --git a/src/resolve/resolved-manager.c b/src/resolve/resolved-manager.c
index dab737d3e4..52695376f0 100644
--- a/src/resolve/resolved-manager.c
+++ b/src/resolve/resolved-manager.c
@@ -534,11 +534,11 @@ Manager *manager_free(Manager *m) {
while (m->dns_queries)
dns_query_free(m->dns_queries);
- dns_scope_free(m->unicast_scope);
-
manager_flush_dns_servers(m, DNS_SERVER_SYSTEM);
manager_flush_dns_servers(m, DNS_SERVER_FALLBACK);
+ dns_scope_free(m->unicast_scope);
+
hashmap_free(m->links);
hashmap_free(m->dns_transactions);
diff --git a/src/shared/prioq.c b/src/shared/prioq.c
index 8af4c51c2f..b89888be0e 100644
--- a/src/shared/prioq.c
+++ b/src/shared/prioq.c
@@ -45,12 +45,14 @@ Prioq *prioq_new(compare_func_t compare_func) {
return q;
}
-void prioq_free(Prioq *q) {
+Prioq* prioq_free(Prioq *q) {
if (!q)
- return;
+ return NULL;
free(q->items);
free(q);
+
+ return NULL;
}
int prioq_ensure_allocated(Prioq **q, compare_func_t compare_func) {
diff --git a/src/shared/prioq.h b/src/shared/prioq.h
index d836b36cd9..1c044b135c 100644
--- a/src/shared/prioq.h
+++ b/src/shared/prioq.h
@@ -28,7 +28,7 @@ typedef struct Prioq Prioq;
#define PRIOQ_IDX_NULL ((unsigned) -1)
Prioq *prioq_new(compare_func_t compare);
-void prioq_free(Prioq *q);
+Prioq *prioq_free(Prioq *q);
int prioq_ensure_allocated(Prioq **q, compare_func_t compare_func);
int prioq_put(Prioq *q, void *data, unsigned *idx);