nyx: utilize ini free and fix various memleaks

With the new changes the heap and heap node usage drops 95% on boot. Subsequent accesses to Launch/More config keep the counter the same.
This commit is contained in:
CTCaer 2022-05-19 15:14:05 +03:00
parent 8428ce1a2e
commit 38010ce65e
7 changed files with 19 additions and 8 deletions

View file

@ -169,6 +169,8 @@ int create_config_entry()
break;
}
}
ini_free(&ini_sections);
}
f_close(&fp);

View file

@ -66,6 +66,8 @@ void load_emummc_cfg(emummc_cfg_t *emu_info)
break;
}
}
ini_free(&ini_sections);
}
void save_emummc_cfg(u32 part_idx, u32 sector_start, const char *path)

View file

@ -1378,14 +1378,10 @@ static lv_res_t _create_mbox_payloads(lv_obj_t *btn)
goto out_end;
}
char *dir = (char *)malloc(256);
strcpy(dir, "bootloader/payloads");
char *filelist = dirlist(dir, NULL, false, false);
char *filelist = dirlist("bootloader/payloads", NULL, false, false);
sd_unmount();
u32 i = 0;
if (filelist)
{
while (true)
@ -1395,6 +1391,7 @@ static lv_res_t _create_mbox_payloads(lv_obj_t *btn)
lv_list_add(list, NULL, &filelist[i * 256], launch_payload);
i++;
}
free(filelist);
}
out_end:
@ -1703,9 +1700,7 @@ static lv_res_t _create_window_home_launch(lv_obj_t *btn)
if (combined_cfg && !ini_parse_success)
{
ini_parsing:
// Reinit list.
ini_sections.prev = &ini_sections;
ini_sections.next = &ini_sections;
list_init(&ini_sections);
ini_parse_success = ini_parse(&ini_sections, "bootloader/ini", true);
more_cfg = true;
}
@ -1851,6 +1846,8 @@ ini_parsing:
break;
}
ini_free(&ini_sections);
ini_parse_failed:
// Reiterate the loop with more cfgs if combined.
if (combined_cfg && (curr_btn_idx < (n_cfg.entries_5_columns ? 10 : 8)) && !more_cfg)

View file

@ -1114,6 +1114,7 @@ out0:;
lv_label_set_text(lv_desc, txt_buf);
lv_obj_align(lv_desc, btn, LV_ALIGN_OUT_BOTTOM_LEFT, 0, LV_DPI / 5);
}
free(txt_buf);
// Create SD File Based container.
lv_obj_t *h2 = lv_cont_create(win, NULL);

View file

@ -56,6 +56,7 @@ static lv_res_t _create_window_dump_done(int error, char *dump_filenames)
s_printf(txt_buf, "Dumping to SD card finished!\nFiles: #C7EA46 backup/%s/dumps/#\n%s", sn, dump_filenames);
}
lv_mbox_set_text(mbox, txt_buf);
free(txt_buf);
lv_mbox_add_btns(mbox, mbox_btn_map, mbox_action); // Important. After set_text.

View file

@ -237,6 +237,8 @@ static void _create_autoboot_window()
lv_list_add(list_main, NULL, ini_sec->name, _autoboot_enable_main_action);
}
ini_free(&ini_sections);
}
// More configuration container.
@ -279,6 +281,8 @@ static void _create_autoboot_window()
lv_list_add(list_more_cfg, NULL, ini_sec->name, _autoboot_enable_more_action);
}
ini_free(&ini_list_sections);
}
sd_unmount();

View file

@ -247,6 +247,8 @@ void load_saved_configuration()
}
}
ini_free(&ini_sections);
skip_main_cfg_parse:
if (!ini_parse(&ini_nyx_sections, "bootloader/nyx.ini", false))
return;
@ -282,6 +284,8 @@ skip_main_cfg_parse:
break;
}
}
ini_free(&ini_nyx_sections);
}
#define EXCP_EN_ADDR 0x4003FFFC