Skip to content
Snippets Groups Projects
Commit d07d51ef authored by Jakob Olsson's avatar Jakob Olsson
Browse files

map-agent: some memory cleanup

parent 4590c35e
Branches
No related tags found
No related merge requests found
......@@ -2868,6 +2868,7 @@ static void parse_radio(struct ubus_request *req, int type,
if (tb[5]) {
struct blob_attr *cur, *cur1;
re->num_supp_opclass = blobmsg_check_array(tb[5], BLOBMSG_TYPE_TABLE);
re->supp_opclass = calloc(re->num_supp_opclass, sizeof(*re->supp_opclass));
if (!re->supp_opclass) {
......@@ -2997,6 +2998,30 @@ static struct wifi_scanres_channel_element *wifi_get_scanres_ch_element(struct w
return 0;
}
static void free_scanresults(struct wifi_radio_element *re)
{
int i;
struct wifi_scanres_element *scanres_el;
int j;
scanres_el = re->scanlist;
for (j = 0; j < scanres_el->num_opclass_scanned; j++) {
int k;
struct wifi_scanres_opclass_element *opclass = &scanres_el->opclass_scanlist[j];
for (k = 0; k < opclass->num_channels_scanned; k++) {
struct wifi_scanres_channel_element *ch_el = &opclass->channel_scanlist[k];
free(ch_el->nbrlist);
}
free(opclass->channel_scanlist);
}
free(scanres_el->opclass_scanlist);
free(scanres_el);
}
static void parse_scanresults(struct ubus_request *req, int type, struct blob_attr *msg)
{
fprintf(stdout, "%s --->\n", __func__);
......@@ -3987,11 +4012,15 @@ void agent_free_radios(struct agent *a)
re = &a->radios[i];
free_scanresults(re);
for (j = 0; j < re->num_supp_opclass; j++) {
free(re->supp_opclass[j].supp_chanlist);
free(re->supp_opclass[j].exclude_chanlist);
}
free(re->bsslist);
free(re->supp_opclass);
agent_free_wsc_data(&re->autconfig);
re->autconfig.key = NULL;
......
......
......@@ -875,6 +875,19 @@ static struct steer_policy *get_steer_policy_by_name(struct netif_fhcfg *c,
return NULL;
}
static struct agent_config_radio *get_agent_config_radio(struct agent_config *c,
const char *ifname)
{
struct agent_config_radio *p;
list_for_each_entry(p, &c->radiolist, list) {
if (!strcmp(ifname, p->name))
return p;
}
return NULL;
}
void stax_add_entry(struct list_head *h, char *sta_macstr)
{
struct stax *n;
......@@ -1406,11 +1419,17 @@ static int agent_config_get_wifi_radio(struct agent_config *a,
}
if (ifname && band) {
n = get_agent_config_radio(a, ifname);
if (!n) {
n = calloc(1, sizeof(*n));
if (!n) {
warn("-ENOMEM!\n");
return -1;
}
list_add_tail(&n->list, &a->radiolist);
}
strncpy(n->name, ifname, 16);
n->name[15] = '\0';
n->band = band;
......@@ -1426,8 +1445,6 @@ static int agent_config_get_wifi_radio(struct agent_config *a,
true : false;
}
list_add_tail(&n->list, &a->radiolist);
return 0;
}
......@@ -2213,13 +2230,29 @@ int clean_all_fh(struct agent_config *cfg)
return 0;
}
void clean_radio_cfg(struct agent_config_radio *p)
{
list_del(&p->list);
free(p);
}
int clean_all_radios(struct agent_config *cfg)
{
struct agent_config_radio *p, *tmp;
list_for_each_entry_safe(p, tmp, &cfg->radiolist, list)
clean_radio_cfg(p);
return 0;
}
int agent_config_clean(struct agent_config *cfg)
{
clean_all_fh(cfg);
clean_all_bk(cfg);
clean_steer_btm_excl(cfg);
clean_steer_excl(cfg);
clean_all_radios(cfg);
if (cfg->pcfg)
free(cfg->pcfg);
......
......
......@@ -220,4 +220,28 @@ void log_cmdu(int level, void *var)
log_test(level, btlv, len);
free(btlv);
}
<<<<<<< HEAD
}
=======
msgversion = json_object_new_int(cmdu->message_version);
msgtype = json_object_new_int(cmdu->message_type);
direction = json_object_new_boolean(flag);
msgid = json_object_new_int(cmdu->message_id);
intfname = json_object_new_string(cmdu->intf_name);
msg = json_object_new_string(map_stringify_cmdu_type(cmdu->message_type));
json_object_object_add(main_object, "message_version", msgversion);
json_object_object_add(main_object, "message_type", msgtype);
json_object_object_add(main_object, "message_id", msgid);
json_object_object_add(main_object, "interface_name", intfname);
json_object_object_add(main_object, "message", msg);
json_object_object_add(main_object, "direction", direction);
json_object_object_add(main_object, "tlvs", tlvarray);
fprintf(testfile, "%s\n", json_object_to_json_string(main_object));
fflush(testfile);
json_object_put(main_object);
}
>>>>>>> 77d3f2a... map-agent: some memory cleanup
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment