Skip to content
Snippets Groups Projects
Commit 57b845da authored by Stanislaw Gruszka's avatar Stanislaw Gruszka Committed by Jakob Olsson
Browse files

free memory at exit

parent ba2d3102
No related branches found
No related tags found
1 merge request!103free memory at exit
Pipeline #46687 passed
......@@ -1337,6 +1337,51 @@ struct node *alloc_node_init(struct controller *c, uint8_t *hwaddr)
return n;
}
#if 0
void node_clean_stalist(struct node *n)
{
struct radio_policy *r = NULL, *tmp;
list_for_each_entry_safe(p, tmp, &n->stalist, list) {
list_del(&->list);
free(p);
}
return 0;
}
#endif
static void radio_clean_iflist(struct netif_radio *r)
{
struct netif_iface *ni = NULL, *tmp;
list_for_each_entry_safe(ni, tmp, &r->iflist, list) {
list_del(&ni->list);
free(ni);
}
}
static void node_clean_radiolist(struct node *n)
{
struct netif_radio *r = NULL, *tmp;
list_for_each_entry_safe(r, tmp, &n->radiolist, list) {
list_del(&r->list);
radio_clean_iflist(r);
free(r);
}
}
static void cntlr_clean_nodelist(struct controller *c)
{
struct node *n = NULL, *tmp;
list_for_each_entry_safe(n, tmp, &c->nodelist, list) {
list_del(&n->list);
node_clean_radiolist(n);
free(n);
}
}
void free_bcn_metrics(struct controller *c, struct sta *s)
{
struct bcn_metrics *b = NULL, *tmp;
......@@ -2361,7 +2406,7 @@ static void cntlr_event_handler(struct ubus_context *ctx,
}
int start_controller(void)
void run_controller(void)
{
struct controller *c;
struct ubus_context *ctx;
......@@ -2376,7 +2421,7 @@ int start_controller(void)
c = calloc(1, sizeof(struct controller));
if (!c)
return -1;
return;
cntlr_dbg("Starting wifi_cntlr... (&cntlr = %p)\n", c);
......@@ -2385,7 +2430,7 @@ int start_controller(void)
if (!ctx) {
err("Failed to connect to ubus\n");
free(c);
return -1;
return;
}
c->ubus_ctx = ctx;
INIT_LIST_HEAD(&c->stalist);
......@@ -2442,16 +2487,15 @@ int start_controller(void)
controller_subscribe_for_cmdus(c);
uloop_run();
out_exit:
ubus_unregister_event_handler(ctx, &c->evh);
map_unsubscribe(ctx, c->subscriber);
cntlr_remove_object(c);
cmdu_ackq_free(&c->cmdu_ack_q);
cntlr_config_clean(&c->cfg);
ubus_free(c->ubus_ctx);
cntlr_clean_nodelist(c);
ubus_free(ctx);
uloop_done();
free(c);
stop_logging();
return 0;
}
......@@ -411,7 +411,6 @@ struct sta_error_response {
#define COMM_HANDLE(c) (((struct controller *)(c))->ubus_ctx)
extern int start_controller(void);
struct node *alloc_node_init(struct controller *c, uint8_t *hwaddr);
struct netif_iface *find_interface_by_ssid(struct controller *c,
struct node *n, char *ssid);
......
......@@ -22,10 +22,9 @@
#include "utils/debug.h"
#include "utils/utils.h"
extern int start_controller(void);
extern int stop_controller(void);
extern void run_controller(void);
const char *PROG_NAME = "wificntlr";
const char *PROG_NAME = "mapcontroller";
int verbose = 2;
bool syslogging;
bool usefifo;
......@@ -103,7 +102,7 @@ int main(int argc, char **argv)
start_logging();
//init_alloctrace("wificntlr");
start_controller();
run_controller();
stop_logging();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment