diff options
| author | Miika Pekkarinen <miipekk@ihme.org> | 2006-09-26 06:40:14 +0000 |
|---|---|---|
| committer | Miika Pekkarinen <miipekk@ihme.org> | 2006-09-26 06:40:14 +0000 |
| commit | 3ae1c103edd2d1a8758af072461c3b4056e1bff8 (patch) | |
| tree | 12656ad7e8c7f9825a9cd1fa89a4201c119fe2b9 /apps | |
| parent | 3bf676ead33b1eebfec67c0a1902191572729fc0 (diff) | |
| download | rockbox-3ae1c103edd2d1a8758af072461c3b4056e1bff8.zip rockbox-3ae1c103edd2d1a8758af072461c3b4056e1bff8.tar.gz rockbox-3ae1c103edd2d1a8758af072461c3b4056e1bff8.tar.bz2 rockbox-3ae1c103edd2d1a8758af072461c3b4056e1bff8.tar.xz | |
Dynamically allocate menu structs.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@11052 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
| -rw-r--r-- | apps/tagtree.c | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/apps/tagtree.c b/apps/tagtree.c index d992c9e..0a1536d 100644 --- a/apps/tagtree.c +++ b/apps/tagtree.c @@ -118,7 +118,7 @@ struct root_menu { /* Statusbar text of the current view. */ static char current_title[MAX_TAGS][128]; -static struct root_menu menus[TAGMENU_MAX_MENUS]; +static struct root_menu *menus[TAGMENU_MAX_MENUS]; static struct root_menu *menu; static struct search_instruction *csi; static const char *strp; @@ -425,10 +425,10 @@ static bool parse_search(struct menu_entry *entry, const char *str) /* Find the matching root menu or "create" it */ for (i = 0; i < menu_count; i++) { - if (!strcasecmp(menus[i].id, buf)) + if (!strcasecmp(menus[i]->id, buf)) { entry->link = i; - menus[i].parent = menu; + menus[i]->parent = menu; return true; } } @@ -634,7 +634,6 @@ static bool parse_menu(const char *filename) { /* End the menu */ menu_count++; - menu = &menus[menu_count]; read_menu = false; } continue; @@ -668,6 +667,9 @@ static bool parse_menu(const char *filename) return false; } + menus[menu_count] = buffer_alloc(sizeof(struct root_menu)); + menu = menus[menu_count]; + memset(menu, 0, sizeof(struct root_menu)); if (get_token_str(menu->id, sizeof(menu->id)) < 0) { logf("%menu_start id empty"); @@ -695,7 +697,7 @@ static bool parse_menu(const char *filename) for (i = 0; i < menu_count; i++) { - if (!strcasecmp(menus[i].id, data)) + if (!strcasecmp(menus[i]->id, data)) { root_menu = i; } @@ -733,9 +735,8 @@ static bool parse_menu(const char *filename) void tagtree_init(void) { - memset(menus, 0, sizeof menus); menu_count = 0; - menu = &menus[0]; + menu = NULL; root_menu = 0; parse_menu(FILE_SEARCH_INSTRUCTIONS); @@ -1040,7 +1041,9 @@ static int load_root(struct tree_context *c) if (c->dirlevel == 0) c->currextra = root_menu; - menu = &menus[c->currextra]; + menu = menus[c->currextra]; + if (menu == NULL) + return 0; for (i = 0; i < menu->itemcount; i++) { @@ -1142,7 +1145,7 @@ int tagtree_enter(struct tree_context* c) if (newextra == root) { - menu = &menus[seek]; + menu = menus[seek]; c->currextra = seek; } |