diff options
author | William Wilgus <wilgus.william@gmail.com> | 2021-10-20 16:05:21 -0400 |
---|---|---|
committer | William Wilgus <wilgus.william@gmail.com> | 2021-10-20 16:05:21 -0400 |
commit | 9878226e4dec1ee7bb1434249214d6d8161b439f (patch) | |
tree | 6946582892b0e4f62c8072a546e95fb2a6a19977 /apps/filetree.c | |
parent | e1553d860dc42a819fe71913d5a68a77fbf64a6e (diff) | |
download | rockbox-9878226e4dec1ee7bb1434249214d6d8161b439f.tar.gz rockbox-9878226e4dec1ee7bb1434249214d6d8161b439f.zip |
filetree.c move static and stack allocated buffers around
it makes more sense to make the main buffer static and make the
second (infrequently needed) buffer as stack allocated
Change-Id: Ide7c1a7a312124e47a23ed0ab75a90d7b8be982e
Diffstat (limited to 'apps/filetree.c')
-rw-r--r-- | apps/filetree.c | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/apps/filetree.c b/apps/filetree.c index 5c6443cc34..66e4a68398 100644 --- a/apps/filetree.c +++ b/apps/filetree.c | |||
@@ -435,7 +435,8 @@ static void ft_load_font(char *file) | |||
435 | int ft_enter(struct tree_context* c) | 435 | int ft_enter(struct tree_context* c) |
436 | { | 436 | { |
437 | int rc = GO_TO_PREVIOUS; | 437 | int rc = GO_TO_PREVIOUS; |
438 | char buf[MAX_PATH]; | 438 | static char buf[MAX_PATH]; |
439 | |||
439 | struct entry* file = tree_get_entry_at(c, c->selected_item); | 440 | struct entry* file = tree_get_entry_at(c, c->selected_item); |
440 | if (!file) | 441 | if (!file) |
441 | { | 442 | { |
@@ -634,17 +635,18 @@ int ft_enter(struct tree_context* c) | |||
634 | case FILE_ATTR_LUA: | 635 | case FILE_ATTR_LUA: |
635 | case FILE_ATTR_OPX: | 636 | case FILE_ATTR_OPX: |
636 | { | 637 | { |
637 | char *plugin = buf, *argument = NULL, lua_path[MAX_PATH]; | 638 | char *plugin = buf, *argument = NULL; |
639 | char plugin_path[MAX_PATH]; | ||
638 | int ret; | 640 | int ret; |
639 | 641 | ||
640 | if ((file_attr & FILE_ATTR_MASK) == FILE_ATTR_LUA) { | 642 | if ((file_attr & FILE_ATTR_MASK) == FILE_ATTR_LUA) { |
641 | snprintf(lua_path, sizeof(lua_path)-1, "%s/lua.rock", VIEWERS_DIR); /* Use a #define here ? */ | 643 | snprintf(plugin_path, sizeof(plugin_path)-1, "%s/lua.rock", VIEWERS_DIR); /* Use a #define here ? */ |
642 | plugin = lua_path; | 644 | plugin = plugin_path; |
643 | argument = buf; | 645 | argument = buf; |
644 | } | 646 | } |
645 | else if ((file_attr & FILE_ATTR_MASK) == FILE_ATTR_OPX) { | 647 | else if ((file_attr & FILE_ATTR_MASK) == FILE_ATTR_OPX) { |
646 | snprintf(lua_path, sizeof(lua_path)-1, "%s/open_plugins.rock", VIEWERS_DIR); /* Use a #define here ? */ | 648 | snprintf(plugin_path, sizeof(plugin_path)-1, "%s/open_plugins.rock", VIEWERS_DIR); /* Use a #define here ? */ |
647 | plugin = lua_path; | 649 | plugin = plugin_path; |
648 | argument = buf; | 650 | argument = buf; |
649 | } | 651 | } |
650 | 652 | ||
@@ -685,7 +687,8 @@ int ft_enter(struct tree_context* c) | |||
685 | default: | 687 | default: |
686 | { | 688 | { |
687 | const char* plugin; | 689 | const char* plugin; |
688 | 690 | char plugin_path[MAX_PATH]; | |
691 | const char *argument = buf; | ||
689 | if (global_settings.party_mode && audio_status()) { | 692 | if (global_settings.party_mode && audio_status()) { |
690 | splash(HZ, ID2P(LANG_PARTY_MODE)); | 693 | splash(HZ, ID2P(LANG_PARTY_MODE)); |
691 | break; | 694 | break; |
@@ -698,10 +701,10 @@ int ft_enter(struct tree_context* c) | |||
698 | return rc; | 701 | return rc; |
699 | } | 702 | } |
700 | 703 | ||
701 | plugin = filetype_get_plugin(file); | 704 | plugin = filetype_get_plugin(file, plugin_path, sizeof(plugin_path)); |
702 | if (plugin) | 705 | if (plugin) |
703 | { | 706 | { |
704 | switch (plugin_load(plugin,buf)) | 707 | switch (plugin_load(plugin, argument)) |
705 | { | 708 | { |
706 | case PLUGIN_USB_CONNECTED: | 709 | case PLUGIN_USB_CONNECTED: |
707 | rc = GO_TO_FILEBROWSER; | 710 | rc = GO_TO_FILEBROWSER; |