[INI] Fix memory leaks + other fixes (#38)

* [INI] Fix memory leaks + other fixes

* Add ini_free
* check and return if NULL pointer in free()
* Add button check with timeout
* Fix a bug in menu rendering that tries to parse a string without existing
* Change initial cnt value to max (fixes menus with first entry not a selectable entry)
* Some & ? clarifications

* [INI] Add get selected boot cfg

- This allows to free ini as we launch the firmware and have the lowest mem leak

* [INI] Rename ini section clone/free functions
This commit is contained in:
Kostas Missos
2018-06-13 02:34:32 +03:00
committed by nwert
parent 62a8618606
commit b2dd070d10
12 changed files with 124 additions and 47 deletions

View File

@@ -40,8 +40,7 @@ void tui_pbar(gfx_con_t *con, int x, int y, u32 val, u32 fgcol, u32 bgcol)
void *tui_do_menu(gfx_con_t *con, menu_t *menu)
{
int idx = 0, cnt = 0;
int prev_idx = 0;
int idx = 0, prev_idx = 0, cnt = 0x7FFFFFFF;
gfx_clear_grey(con->gfx_ctxt, 0x1B);
@@ -56,7 +55,7 @@ void *tui_do_menu(gfx_con_t *con, menu_t *menu)
menu->ents[idx].type == MENT_CHGLINE)
{
if (prev_idx <= idx || (!idx && prev_idx == cnt - 1))
{
{
idx++;
if (idx > (cnt - 1))
{
@@ -83,9 +82,9 @@ void *tui_do_menu(gfx_con_t *con, menu_t *menu)
gfx_con_setcol(con, 0xFF1B1B1B, 1, 0xFFCCCCCC);
else
gfx_con_setcol(con, 0xFFCCCCCC, 1, 0xFF1B1B1B);
if (cnt != idx && menu->ents[cnt].type == MENT_CAPTION)
if (menu->ents[cnt].type == MENT_CAPTION)
gfx_printf(con, "%k %s", menu->ents[cnt].color, menu->ents[cnt].caption);
else
else if (menu->ents[cnt].type != MENT_CHGLINE)
gfx_printf(con, " %s", menu->ents[cnt].caption);
if(menu->ents[cnt].type == MENT_MENU)
gfx_printf(con, "%k...", 0xFFEE9900);