diff options
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 d992c9e32a..0a1536d571 100644 --- a/apps/tagtree.c +++ b/apps/tagtree.c | |||
@@ -118,7 +118,7 @@ struct root_menu { | |||
118 | /* Statusbar text of the current view. */ | 118 | /* Statusbar text of the current view. */ |
119 | static char current_title[MAX_TAGS][128]; | 119 | static char current_title[MAX_TAGS][128]; |
120 | 120 | ||
121 | static struct root_menu menus[TAGMENU_MAX_MENUS]; | 121 | static struct root_menu *menus[TAGMENU_MAX_MENUS]; |
122 | static struct root_menu *menu; | 122 | static struct root_menu *menu; |
123 | static struct search_instruction *csi; | 123 | static struct search_instruction *csi; |
124 | static const char *strp; | 124 | static const char *strp; |
@@ -425,10 +425,10 @@ static bool parse_search(struct menu_entry *entry, const char *str) | |||
425 | /* Find the matching root menu or "create" it */ | 425 | /* Find the matching root menu or "create" it */ |
426 | for (i = 0; i < menu_count; i++) | 426 | for (i = 0; i < menu_count; i++) |
427 | { | 427 | { |
428 | if (!strcasecmp(menus[i].id, buf)) | 428 | if (!strcasecmp(menus[i]->id, buf)) |
429 | { | 429 | { |
430 | entry->link = i; | 430 | entry->link = i; |
431 | menus[i].parent = menu; | 431 | menus[i]->parent = menu; |
432 | return true; | 432 | return true; |
433 | } | 433 | } |
434 | } | 434 | } |
@@ -634,7 +634,6 @@ static bool parse_menu(const char *filename) | |||
634 | { | 634 | { |
635 | /* End the menu */ | 635 | /* End the menu */ |
636 | menu_count++; | 636 | menu_count++; |
637 | menu = &menus[menu_count]; | ||
638 | read_menu = false; | 637 | read_menu = false; |
639 | } | 638 | } |
640 | continue; | 639 | continue; |
@@ -668,6 +667,9 @@ static bool parse_menu(const char *filename) | |||
668 | return false; | 667 | return false; |
669 | } | 668 | } |
670 | 669 | ||
670 | menus[menu_count] = buffer_alloc(sizeof(struct root_menu)); | ||
671 | menu = menus[menu_count]; | ||
672 | memset(menu, 0, sizeof(struct root_menu)); | ||
671 | if (get_token_str(menu->id, sizeof(menu->id)) < 0) | 673 | if (get_token_str(menu->id, sizeof(menu->id)) < 0) |
672 | { | 674 | { |
673 | logf("%menu_start id empty"); | 675 | logf("%menu_start id empty"); |
@@ -695,7 +697,7 @@ static bool parse_menu(const char *filename) | |||
695 | 697 | ||
696 | for (i = 0; i < menu_count; i++) | 698 | for (i = 0; i < menu_count; i++) |
697 | { | 699 | { |
698 | if (!strcasecmp(menus[i].id, data)) | 700 | if (!strcasecmp(menus[i]->id, data)) |
699 | { | 701 | { |
700 | root_menu = i; | 702 | root_menu = i; |
701 | } | 703 | } |
@@ -733,9 +735,8 @@ static bool parse_menu(const char *filename) | |||
733 | 735 | ||
734 | void tagtree_init(void) | 736 | void tagtree_init(void) |
735 | { | 737 | { |
736 | memset(menus, 0, sizeof menus); | ||
737 | menu_count = 0; | 738 | menu_count = 0; |
738 | menu = &menus[0]; | 739 | menu = NULL; |
739 | root_menu = 0; | 740 | root_menu = 0; |
740 | parse_menu(FILE_SEARCH_INSTRUCTIONS); | 741 | parse_menu(FILE_SEARCH_INSTRUCTIONS); |
741 | 742 | ||
@@ -1040,7 +1041,9 @@ static int load_root(struct tree_context *c) | |||
1040 | if (c->dirlevel == 0) | 1041 | if (c->dirlevel == 0) |
1041 | c->currextra = root_menu; | 1042 | c->currextra = root_menu; |
1042 | 1043 | ||
1043 | menu = &menus[c->currextra]; | 1044 | menu = menus[c->currextra]; |
1045 | if (menu == NULL) | ||
1046 | return 0; | ||
1044 | 1047 | ||
1045 | for (i = 0; i < menu->itemcount; i++) | 1048 | for (i = 0; i < menu->itemcount; i++) |
1046 | { | 1049 | { |
@@ -1142,7 +1145,7 @@ int tagtree_enter(struct tree_context* c) | |||
1142 | 1145 | ||
1143 | if (newextra == root) | 1146 | if (newextra == root) |
1144 | { | 1147 | { |
1145 | menu = &menus[seek]; | 1148 | menu = menus[seek]; |
1146 | c->currextra = seek; | 1149 | c->currextra = seek; |
1147 | } | 1150 | } |
1148 | 1151 | ||