*: Convert connected_free to a double pointer

Set the connected pointer to set the pointer to NULL.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
This commit is contained in:
Donald Sharp 2019-10-29 20:16:28 -04:00
parent 63265b5c1f
commit 721c08573a
17 changed files with 39 additions and 29 deletions

View file

@ -357,7 +357,7 @@ static int bgp_interface_address_delete(ZAPI_CALLBACK_ARGS)
bgp_connected_delete(bgp, ifc);
}
connected_free(ifc);
connected_free(&ifc);
return 0;
}

View file

@ -189,7 +189,7 @@ static int eigrp_interface_address_delete(ZAPI_CALLBACK_ARGS)
if (prefix_cmp(&ei->address, c->address) == 0)
eigrp_if_free(ei, INTERFACE_DOWN_BY_ZEBRA);
connected_free(c);
connected_free(&c);
return 0;
}

View file

@ -128,7 +128,7 @@ static int isis_zebra_if_address_del(ZAPI_CALLBACK_ARGS)
if (if_is_operative(ifp))
isis_circuit_del_addr(circuit_scan_by_ifp(ifp), c);
connected_free(c);
connected_free(&c);
return 0;
}

View file

@ -368,7 +368,7 @@ ldp_interface_address_delete(ZAPI_CALLBACK_ARGS)
ifp = ifc->ifp;
ifc2kaddr(ifp, ifc, &ka);
connected_free(ifc);
connected_free(&ifc);
/* Filter invalid addresses. */
if (bad_addr(ka.af, &ka.addr))

View file

@ -140,6 +140,13 @@ static int if_cmp_index_func(const struct interface *ifp1,
return ifp1->ifindex - ifp2->ifindex;
}
static void ifp_connected_free(void *arg)
{
struct connected *c = arg;
connected_free(&c);
}
/* Create new interface structure. */
static struct interface *if_new(vrf_id_t vrf_id)
{
@ -153,7 +160,7 @@ static struct interface *if_new(vrf_id_t vrf_id)
ifp->vrf_id = vrf_id;
ifp->connected = list_new();
ifp->connected->del = (void (*)(void *))connected_free;
ifp->connected->del = ifp_connected_free;
ifp->nbr_connected = list_new();
ifp->nbr_connected->del = (void (*)(void *))nbr_connected_free;
@ -866,17 +873,20 @@ struct nbr_connected *nbr_connected_new(void)
}
/* Free connected structure. */
void connected_free(struct connected *connected)
void connected_free(struct connected **connected)
{
if (connected->address)
prefix_free(&connected->address);
struct connected *ptr = *connected;
if (connected->destination)
prefix_free(&connected->destination);
if (ptr->address)
prefix_free(&ptr->address);
XFREE(MTYPE_CONNECTED_LABEL, connected->label);
if (ptr->destination)
prefix_free(&ptr->destination);
XFREE(MTYPE_CONNECTED, connected);
XFREE(MTYPE_CONNECTED_LABEL, ptr->label);
XFREE(MTYPE_CONNECTED, ptr);
*connected = NULL;
}
/* Free nbr connected structure. */

View file

@ -543,7 +543,7 @@ extern ifindex_t ifname2ifindex(const char *ifname, vrf_id_t vrf_id);
/* Connected address functions. */
extern struct connected *connected_new(void);
extern void connected_free(struct connected *);
extern void connected_free(struct connected **connected);
extern void connected_add(struct interface *, struct connected *);
extern struct connected *
connected_add_by_prefix(struct interface *, struct prefix *, struct prefix *);

View file

@ -364,7 +364,7 @@ int nhrp_interface_address_delete(ZAPI_CALLBACK_ARGS)
nhrp_interface_update_address(
ifc->ifp, family2afi(PREFIX_FAMILY(ifc->address)), 0);
connected_free(ifc);
connected_free(&ifc);
return 0;
}

View file

@ -143,7 +143,7 @@ static int ospf6_zebra_if_address_update_delete(ZAPI_CALLBACK_ARGS)
ospf6_interface_state_update(c->ifp);
}
connected_free(c);
connected_free(&c);
return 0;
}

View file

@ -150,7 +150,7 @@ static int ospf_interface_address_delete(ZAPI_CALLBACK_ARGS)
rn = route_node_lookup(IF_OIFS(ifp), &p);
if (!rn) {
connected_free(c);
connected_free(&c);
return 0;
}
@ -163,7 +163,7 @@ static int ospf_interface_address_delete(ZAPI_CALLBACK_ARGS)
ospf_if_interface(c->ifp);
connected_free(c);
connected_free(&c);
return 0;
}

View file

@ -109,7 +109,7 @@ static int interface_address_delete(ZAPI_CALLBACK_ARGS)
"%s: %s deleted %s", __PRETTY_FUNCTION__, c->ifp->name,
prefix2str(c->address, buf, sizeof(buf)));
connected_free(c);
connected_free(&c);
return 0;
}

View file

@ -233,7 +233,7 @@ static int pim_zebra_if_address_del(ZAPI_CALLBACK_ARGS)
pim_i_am_rp_re_evaluate(pim);
}
connected_free(c);
connected_free(&c);
return 0;
}

View file

@ -648,7 +648,7 @@ int rip_interface_address_delete(ZAPI_CALLBACK_ARGS)
rip_apply_address_del(ifc);
}
connected_free(ifc);
connected_free(&ifc);
}
return 0;

View file

@ -430,7 +430,7 @@ int ripng_interface_address_delete(ZAPI_CALLBACK_ARGS)
/* Check wether this prefix needs to be removed. */
ripng_apply_address_del(ifc);
}
connected_free(ifc);
connected_free(&ifc);
}
return 0;

View file

@ -73,7 +73,7 @@ static int interface_address_delete(ZAPI_CALLBACK_ARGS)
if (!c)
return 0;
connected_free(c);
connected_free(&c);
return 0;
}

View file

@ -79,7 +79,7 @@ static int interface_address_delete(ZAPI_CALLBACK_ARGS)
if (!c)
return 0;
connected_free(c);
connected_free(&c);
return 0;
}

View file

@ -65,7 +65,7 @@ static void connected_withdraw(struct connected *ifc)
if (!CHECK_FLAG(ifc->conf, ZEBRA_IFC_CONFIGURED)) {
listnode_delete(ifc->ifp->connected, ifc);
connected_free(ifc);
connected_free(&ifc);
}
}
@ -177,7 +177,7 @@ static void connected_update(struct interface *ifp, struct connected *ifc)
*/
if (connected_same(current, ifc)) {
/* nothing to do */
connected_free(ifc);
connected_free(&ifc);
return;
}

View file

@ -738,7 +738,7 @@ static void if_delete_connected(struct interface *ifp)
ZEBRA_IFC_CONFIGURED)) {
listnode_delete(ifp->connected,
ifc);
connected_free(ifc);
connected_free(&ifc);
} else
last = node;
}
@ -759,7 +759,7 @@ static void if_delete_connected(struct interface *ifp)
last = node;
else {
listnode_delete(ifp->connected, ifc);
connected_free(ifc);
connected_free(&ifc);
}
} else {
last = node;
@ -2878,7 +2878,7 @@ static int ip_address_uninstall(struct vty *vty, struct interface *ifp,
if (!CHECK_FLAG(ifc->conf, ZEBRA_IFC_QUEUED)
|| !CHECK_FLAG(ifp->status, ZEBRA_INTERFACE_ACTIVE)) {
listnode_delete(ifp->connected, ifc);
connected_free(ifc);
connected_free(&ifc);
return CMD_WARNING_CONFIG_FAILED;
}
@ -3103,7 +3103,7 @@ static int ipv6_address_uninstall(struct vty *vty, struct interface *ifp,
if (!CHECK_FLAG(ifc->conf, ZEBRA_IFC_QUEUED)
|| !CHECK_FLAG(ifp->status, ZEBRA_INTERFACE_ACTIVE)) {
listnode_delete(ifp->connected, ifc);
connected_free(ifc);
connected_free(&ifc);
return CMD_WARNING_CONFIG_FAILED;
}