diff options
-rw-r--r-- | common/menu.c | 4 | ||||
-rw-r--r-- | include/menu.h | 9 |
2 files changed, 8 insertions, 5 deletions
diff --git a/common/menu.c b/common/menu.c index b20164415c..9c40365e1a 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 4405cedfac..128d671b0b 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); |