[PATCH 3/9] menu: simplify menu_free with list_for_each_entry_safe

Sascha Hauer s.hauer at pengutronix.de
Mon Aug 23 02:24:07 EDT 2010


Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 common/menu.c |   12 +++---------
 1 files changed, 3 insertions(+), 9 deletions(-)

diff --git a/common/menu.c b/common/menu.c
index 9c40365..6fd74a0 100644
--- a/common/menu.c
+++ b/common/menu.c
@@ -39,21 +39,15 @@ struct menu* menu_get_menus(void)
 
 void menu_free(struct menu *m)
 {
-	struct list_head *pos;
-	struct menu_entry *me;
+	struct menu_entry *me, *tmp;
 
 	if (!m)
 		return;
 	free(m->name);
 	free(m->display);
 
-	pos = &m->entries.list;
-
-	if (pos->prev != pos->next && pos->prev != 0)
-		list_for_each(pos, &m->entries.list) {
-			me = list_entry(pos, struct menu_entry, list);
-			menu_entry_free(me);
-		}
+	list_for_each_entry_safe(me, tmp, &m->entries.list, list)
+		menu_entry_free(me);
 
 	free(m);
 }
-- 
1.7.1




More information about the barebox mailing list