From 812e0df4b822e057de466bd4b4322c422e6e485d Mon Sep 17 00:00:00 2001 From: Richard Cochran Date: Mon, 10 Feb 2020 20:57:41 -0800 Subject: [PATCH] config: Use the proper create/destroy API for network interfaces. Signed-off-by: Richard Cochran Reviewed-by: Jacob Keller --- config.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/config.c b/config.c index 717ee65..e033842 100644 --- a/config.c +++ b/config.c @@ -829,13 +829,11 @@ struct interface *config_create_interface(const char *name, struct config *cfg) return iface; } - iface = calloc(1, sizeof(struct interface)); + iface = interface_create(name); if (!iface) { fprintf(stderr, "cannot allocate memory for a port\n"); return NULL; } - - interface_set_name(iface, name); STAILQ_INSERT_TAIL(&cfg->interfaces, iface, list); cfg->n_interfaces++; @@ -906,7 +904,7 @@ void config_destroy(struct config *cfg) while ((iface = STAILQ_FIRST(&cfg->interfaces))) { STAILQ_REMOVE_HEAD(&cfg->interfaces, list); - free(iface); + interface_destroy(iface); } while ((table = STAILQ_FIRST(&cfg->unicast_master_tables))) { while ((address = STAILQ_FIRST(&table->addrs))) {