Signed-off-by: Vitezslav Samel <vitezslav(a)samel.cz>
---
src/tui/menurt.c | 21 ++++++++-------------
1 file changed, 8 insertions(+), 13 deletions(-)
diff --git a/src/tui/menurt.c b/src/tui/menurt.c
index b4c153a..fb3f002 100644
--- a/src/tui/menurt.c
+++ b/src/tui/menurt.c
@@ -261,26 +261,21 @@ void tx_operatemenu(struct MENU *menu, int *position, int *aborted)
doupdate();
}
-
void tx_destroymenu(struct MENU *menu)
{
- struct ITEM *tnode;
- struct ITEM *tnextnode;
-
- if (menu->itemlist != NULL) {
- tnode = menu->itemlist;
- tnextnode = menu->itemlist->next;
+ struct ITEM *tnode = menu->itemlist;
+ /* break the circular list */
+ if (tnode != NULL)
tnode->prev->next = NULL;
- while (tnode != NULL) {
- free(tnode);
- tnode = tnextnode;
+ while (tnode != NULL) {
+ struct ITEM *tnextnode = tnode->next;
- if (tnextnode != NULL)
- tnextnode = tnextnode->next;
- }
+ free(tnode);
+ tnode = tnextnode;
}
+
del_panel(menu->menupanel);
delwin(menu->menuwin);
update_panels();
--
1.9.1