From: Vincent Bernat Date: Tue, 9 Dec 2008 17:28:24 +0000 (+0100) Subject: Factorize out cleanup of lldpd_hardware structure X-Git-Tag: 0.3~12^2~5 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d9be8ea0aa1aabc344bea2cf9a99321c2a487dce;p=thirdparty%2Flldpd.git Factorize out cleanup of lldpd_hardware structure --- diff --git a/src/lldpd.c b/src/lldpd.c index 7892553d..661432ff 100644 --- a/src/lldpd.c +++ b/src/lldpd.c @@ -414,6 +414,17 @@ lldpd_remote_cleanup(struct lldpd *cfg, struct lldpd_hardware *hardware, int res } } +void +lldpd_hardware_cleanup(struct lldpd_hardware *hardware) +{ +#ifdef ENABLE_DOT1 + lldpd_vlan_cleanup(&hardware->h_lport); +#endif + free(hardware->h_proto_macs); + free(hardware->h_llastframe); + free(hardware); +} + void lldpd_cleanup(struct lldpd *cfg) { @@ -426,13 +437,8 @@ lldpd_cleanup(struct lldpd *cfg) if (hardware->h_flags == 0) { TAILQ_REMOVE(&cfg->g_hardware, hardware, h_entries); lldpd_iface_close(cfg, hardware); -#ifdef ENABLE_DOT1 - lldpd_vlan_cleanup(&hardware->h_lport); -#endif lldpd_remote_cleanup(cfg, hardware, 1); - free(hardware->h_proto_macs); - free(hardware->h_llastframe); - free(hardware); + lldpd_hardware_cleanup(hardware); } else if (hardware->h_rchassis != NULL) { if (time(NULL) - hardware->h_rlastupdate > hardware->h_rchassis->c_ttl) { @@ -682,11 +688,7 @@ lldpd_port_add(struct lldpd *cfg, struct ifaddrs *ifa) if (lldpd_iface_init(cfg, hardware) != 0) { LLOG_WARN("unable to initialize %s", hardware->h_ifname); -#ifdef ENABLE_DOT1 - lldpd_vlan_cleanup(&hardware->h_lport); -#endif - free(hardware->h_proto_macs); - free(hardware); + lldpd_hardware_cleanup(hardware); return (NULL); } diff --git a/src/lldpd.h b/src/lldpd.h index b65b815a..33fe5f2b 100644 --- a/src/lldpd.h +++ b/src/lldpd.h @@ -277,6 +277,7 @@ struct hmsg { /* lldpd.c */ void lldpd_cleanup(struct lldpd *); +void lldpd_hardware_cleanup(struct lldpd_hardware *); #ifdef ENABLE_DOT1 void lldpd_vlan_cleanup(struct lldpd_port *); #endif