summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--common/menu.c4
-rw-r--r--include/menu.h9
2 files changed, 8 insertions, 5 deletions
diff --git a/common/menu.c b/common/menu.c
index b201644..9c40365 100644
--- a/common/menu.c
+++ b/common/menu.c
@@ -68,10 +68,6 @@ int menu_add(struct menu *m)
list_add_tail(&m->list, &menus.list);
- m->nb_entries = 0;
-
- INIT_LIST_HEAD(&m->entries.list);
-
return 0;
}
diff --git a/include/menu.h b/include/menu.h
index 4405ced..128d671 100644
--- a/include/menu.h
+++ b/include/menu.h
@@ -55,7 +55,14 @@ struct menu {
*/
static inline struct menu* menu_alloc(void)
{
- return calloc(1, sizeof(struct menu));
+ struct menu *m;
+
+ m = calloc(1, sizeof(struct menu));
+ if (m) {
+ INIT_LIST_HEAD(&m->entries.list);
+ m->nb_entries = 0;
+ }
+ return m;
}
void menu_free(struct menu *m);
int menu_add(struct menu* m);