mirror of
https://github.com/pi-hole/dnsmasq.git
synced 2025-12-19 10:18:25 +00:00
Reduce code duplication, reuse existing functions
dhcp_config_free and dhcp_opt_free already implement the same algorithm. Reuse them. Adds forgotten hostname cleanup to config free.
This commit is contained in:
committed by
Simon Kelley
parent
ffd3ceb856
commit
10d8b5f001
42
src/option.c
42
src/option.c
@@ -1067,6 +1067,8 @@ static void dhcp_config_free(struct dhcp_config *config)
|
|||||||
|
|
||||||
if (config->flags & CONFIG_CLID)
|
if (config->flags & CONFIG_CLID)
|
||||||
free(config->clid);
|
free(config->clid);
|
||||||
|
if (config->flags & CONFIG_NAME)
|
||||||
|
free(config->hostname);
|
||||||
|
|
||||||
#ifdef HAVE_DHCP6
|
#ifdef HAVE_DHCP6
|
||||||
if (config->flags & CONFIG_ADDR6)
|
if (config->flags & CONFIG_ADDR6)
|
||||||
@@ -5002,30 +5004,8 @@ static void clear_dynamic_conf(void)
|
|||||||
|
|
||||||
if (configs->flags & CONFIG_BANK)
|
if (configs->flags & CONFIG_BANK)
|
||||||
{
|
{
|
||||||
struct hwaddr_config *mac, *tmp;
|
*up = cp;
|
||||||
struct dhcp_netid_list *list, *tmplist;
|
dhcp_config_free(configs);
|
||||||
|
|
||||||
for (mac = configs->hwaddr; mac; mac = tmp)
|
|
||||||
{
|
|
||||||
tmp = mac->next;
|
|
||||||
free(mac);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (configs->flags & CONFIG_CLID)
|
|
||||||
free(configs->clid);
|
|
||||||
|
|
||||||
for (list = configs->netid; list; list = tmplist)
|
|
||||||
{
|
|
||||||
free(list->list);
|
|
||||||
tmplist = list->next;
|
|
||||||
free(list);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (configs->flags & CONFIG_NAME)
|
|
||||||
free(configs->hostname);
|
|
||||||
|
|
||||||
*up = configs->next;
|
|
||||||
free(configs);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
up = &configs->next;
|
up = &configs->next;
|
||||||
@@ -5035,7 +5015,6 @@ static void clear_dynamic_conf(void)
|
|||||||
static void clear_dynamic_opt(void)
|
static void clear_dynamic_opt(void)
|
||||||
{
|
{
|
||||||
struct dhcp_opt *opts, *cp, **up;
|
struct dhcp_opt *opts, *cp, **up;
|
||||||
struct dhcp_netid *id, *next;
|
|
||||||
|
|
||||||
for (up = &daemon->dhcp_opts, opts = daemon->dhcp_opts; opts; opts = cp)
|
for (up = &daemon->dhcp_opts, opts = daemon->dhcp_opts; opts; opts = cp)
|
||||||
{
|
{
|
||||||
@@ -5043,17 +5022,8 @@ static void clear_dynamic_opt(void)
|
|||||||
|
|
||||||
if (opts->flags & DHOPT_BANK)
|
if (opts->flags & DHOPT_BANK)
|
||||||
{
|
{
|
||||||
if ((opts->flags & DHOPT_VENDOR))
|
*up = cp;
|
||||||
free(opts->u.vendor_class);
|
dhcp_opt_free(opts);
|
||||||
free(opts->val);
|
|
||||||
for (id = opts->netid; id; id = next)
|
|
||||||
{
|
|
||||||
next = id->next;
|
|
||||||
free(id->net);
|
|
||||||
free(id);
|
|
||||||
}
|
|
||||||
*up = opts->next;
|
|
||||||
free(opts);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
up = &opts->next;
|
up = &opts->next;
|
||||||
|
|||||||
Reference in New Issue
Block a user