/* SPDX-License-Identifier: LGPL-2.1+ */
-/***
- This file is part of systemd.
-
- Copyright 2016 Lennart Poettering
-***/
#include "fd-util.h"
#include "fileio.h"
};
static int add_item(Manager *m, int family, const union in_addr_union *address, char **names) {
-
+ _cleanup_strv_free_ char **dummy = names;
EtcHostsItem key = {
.family = family,
.address = *address,
if (r < 0)
return log_oom();
- item = new0(EtcHostsItem, 1);
+ item = new(EtcHostsItem, 1);
if (!item)
return log_oom();
- item->family = family;
- item->address = *address;
- item->names = names;
+ *item = (EtcHostsItem) {
+ .family = family,
+ .address = *address,
+ .names = names,
+ };
r = set_put(m->etc_hosts_by_address, item);
if (r < 0) {
free(item);
return log_oom();
}
+
+ dummy = NULL;
}
}
return r;
}
-int manager_etc_hosts_read(Manager *m) {
+static int manager_etc_hosts_read(Manager *m) {
_cleanup_fclose_ FILE *f = NULL;
char line[LINE_MAX];
struct stat st;
assert(q);
assert(answer);
+ if (!m->read_etc_hosts)
+ return 0;
+
r = manager_etc_hosts_read(m);
if (r < 0)
return r;