summaryrefslogtreecommitdiff
path: root/src/resolve-host/resolve-host.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2015-12-21 16:31:29 +0100
committerLennart Poettering <lennart@poettering.net>2015-12-26 19:09:10 +0100
commit7b50eb2efa122200e39646c19a29abab302f7d24 (patch)
tree32160f39e5bf23474815e1d21d02ce2739557884 /src/resolve-host/resolve-host.c
parent0936416a1cba187dc76903dae73246f4cbddf312 (diff)
downloadsystemd-7b50eb2efa122200e39646c19a29abab302f7d24.tar.gz
resolved: internalize string buffer of dns_resource_record_to_string()
Let's simplify usage and memory management of DnsResourceRecord's dns_resource_record_to_string() call: cache the formatted string as part of the object, and return it on subsequent calls, freeing it when the DnsResourceRecord itself is freed.
Diffstat (limited to 'src/resolve-host/resolve-host.c')
-rw-r--r--src/resolve-host/resolve-host.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/resolve-host/resolve-host.c b/src/resolve-host/resolve-host.c
index 3f3563850b..4752992cba 100644
--- a/src/resolve-host/resolve-host.c
+++ b/src/resolve-host/resolve-host.c
@@ -368,7 +368,7 @@ static int resolve_record(sd_bus *bus, const char *name) {
while ((r = sd_bus_message_enter_container(reply, 'r', "iqqay")) > 0) {
_cleanup_(dns_resource_record_unrefp) DnsResourceRecord *rr = NULL;
_cleanup_(dns_packet_unrefp) DnsPacket *p = NULL;
- _cleanup_free_ char *s = NULL;
+ const char *s;
uint16_t c, t;
int ifindex;
const void *d;
@@ -402,10 +402,10 @@ static int resolve_record(sd_bus *bus, const char *name) {
if (r < 0)
return log_error_errno(r, "Failed to parse RR.");
- r = dns_resource_record_to_string(rr, &s);
- if (r < 0) {
+ s = dns_resource_record_to_string(rr);
+ if (!s) {
log_error("Failed to format RR.");
- return r;
+ return -ENOMEM;
}
ifname[0] = 0;