mirror of
https://github.com/systemd/systemd
synced 2024-07-21 18:24:38 +00:00
resolve: rename etc_hosts_free() -> etc_hosts_clear()
This commit is contained in:
parent
10b89c59dc
commit
0f7bdf3503
|
@ -6,7 +6,7 @@
|
|||
|
||||
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
|
||||
_cleanup_fclose_ FILE *f = NULL;
|
||||
_cleanup_(etc_hosts_free) EtcHosts h = {};
|
||||
_cleanup_(etc_hosts_clear) EtcHosts h = {};
|
||||
|
||||
if (!getenv("SYSTEMD_LOG_LEVEL"))
|
||||
log_set_max_level(LOG_CRIT);
|
||||
|
|
|
@ -29,14 +29,16 @@ static void etc_hosts_item_by_name_free(EtcHostsItemByName *item) {
|
|||
free(item);
|
||||
}
|
||||
|
||||
void etc_hosts_free(EtcHosts *hosts) {
|
||||
void etc_hosts_clear(EtcHosts *hosts) {
|
||||
assert(hosts);
|
||||
|
||||
hosts->by_address = hashmap_free_with_destructor(hosts->by_address, etc_hosts_item_free);
|
||||
hosts->by_name = hashmap_free_with_destructor(hosts->by_name, etc_hosts_item_by_name_free);
|
||||
hosts->no_address = set_free_free(hosts->no_address);
|
||||
}
|
||||
|
||||
void manager_etc_hosts_flush(Manager *m) {
|
||||
etc_hosts_free(&m->etc_hosts);
|
||||
etc_hosts_clear(&m->etc_hosts);
|
||||
m->etc_hosts_stat = (struct stat) {};
|
||||
}
|
||||
|
||||
|
@ -251,7 +253,7 @@ static void strip_localhost(EtcHosts *hosts) {
|
|||
}
|
||||
|
||||
int etc_hosts_parse(EtcHosts *hosts, FILE *f) {
|
||||
_cleanup_(etc_hosts_free) EtcHosts t = {};
|
||||
_cleanup_(etc_hosts_clear) EtcHosts t = {};
|
||||
unsigned nr = 0;
|
||||
int r;
|
||||
|
||||
|
@ -282,7 +284,7 @@ int etc_hosts_parse(EtcHosts *hosts, FILE *f) {
|
|||
|
||||
strip_localhost(&t);
|
||||
|
||||
etc_hosts_free(hosts);
|
||||
etc_hosts_clear(hosts);
|
||||
*hosts = t;
|
||||
t = (EtcHosts) {}; /* prevent cleanup */
|
||||
return 0;
|
||||
|
|
|
@ -20,7 +20,7 @@ typedef struct EtcHostsItemByName {
|
|||
} EtcHostsItemByName;
|
||||
|
||||
int etc_hosts_parse(EtcHosts *hosts, FILE *f);
|
||||
void etc_hosts_free(EtcHosts *hosts);
|
||||
void etc_hosts_clear(EtcHosts *hosts);
|
||||
|
||||
void manager_etc_hosts_flush(Manager *m);
|
||||
int manager_etc_hosts_lookup(Manager *m, DnsQuestion* q, DnsAnswer **answer);
|
||||
|
|
|
@ -23,7 +23,7 @@ TEST(parse_etc_hosts_system) {
|
|||
return;
|
||||
}
|
||||
|
||||
_cleanup_(etc_hosts_free) EtcHosts hosts = {};
|
||||
_cleanup_(etc_hosts_clear) EtcHosts hosts = {};
|
||||
assert_se(etc_hosts_parse(&hosts, f) == 0);
|
||||
}
|
||||
|
||||
|
@ -67,7 +67,7 @@ TEST(parse_etc_hosts) {
|
|||
assert_se(fflush_and_check(f) >= 0);
|
||||
rewind(f);
|
||||
|
||||
_cleanup_(etc_hosts_free) EtcHosts hosts = {};
|
||||
_cleanup_(etc_hosts_clear) EtcHosts hosts = {};
|
||||
assert_se(etc_hosts_parse(&hosts, f) == 0);
|
||||
|
||||
EtcHostsItemByName *bn;
|
||||
|
@ -124,7 +124,7 @@ TEST(parse_etc_hosts) {
|
|||
}
|
||||
|
||||
static void test_parse_file_one(const char *fname) {
|
||||
_cleanup_(etc_hosts_free) EtcHosts hosts = {};
|
||||
_cleanup_(etc_hosts_clear) EtcHosts hosts = {};
|
||||
_cleanup_fclose_ FILE *f;
|
||||
|
||||
log_info("/* %s(\"%s\") */", __func__, fname);
|
||||
|
|
Loading…
Reference in a new issue