diff options
author | Nils Wallménius <nils@rockbox.org> | 2008-04-09 15:25:17 +0000 |
---|---|---|
committer | Nils Wallménius <nils@rockbox.org> | 2008-04-09 15:25:17 +0000 |
commit | 6848961aa5f93a290917071ff3496e1d5026621b (patch) | |
tree | 70d377348ab0694c356fffd9fe25f095ccbe88fe /apps/gui | |
parent | ae64d2602befd5589c8c0141a6d812841fdfb232 (diff) |
Pass the buffer length to the list_get_name callback functions instead of using hardcoded MAX_PATH
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@17049 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/gui')
-rw-r--r-- | apps/gui/bitmap/list.c | 3 | ||||
-rw-r--r-- | apps/gui/charcell/list.c | 3 | ||||
-rw-r--r-- | apps/gui/list.c | 10 | ||||
-rw-r--r-- | apps/gui/list.h | 4 | ||||
-rw-r--r-- | apps/gui/option_select.c | 6 |
5 files changed, 18 insertions, 8 deletions
diff --git a/apps/gui/bitmap/list.c b/apps/gui/bitmap/list.c index 13329e22f9..869acc539c 100644 --- a/apps/gui/bitmap/list.c +++ b/apps/gui/bitmap/list.c @@ -178,7 +178,8 @@ void list_draw(struct screen *display, struct viewport *parent, char entry_buffer[MAX_PATH]; unsigned char *entry_name; int text_pos = 0; - s = list->callback_get_item_name(i, list->data, entry_buffer); + s = list->callback_get_item_name(i, list->data, entry_buffer, + sizeof(entry_buffer)); entry_name = P2STR(s); display->set_viewport(&list_text[display->screen_type]); list_text[display->screen_type].drawmode = STYLE_DEFAULT; diff --git a/apps/gui/charcell/list.c b/apps/gui/charcell/list.c index 3d699e84dd..64f2fecbbd 100644 --- a/apps/gui/charcell/list.c +++ b/apps/gui/charcell/list.c @@ -82,7 +82,8 @@ void list_draw(struct screen *display, struct viewport *parent, break; s = gui_list->callback_get_item_name(current_item, gui_list->data, - entry_buffer); + entry_buffer, + sizeof(entry_buffer)); entry_name = P2STR(s); diff --git a/apps/gui/list.c b/apps/gui/list.c index 07ef578d29..2ba4d4e762 100644 --- a/apps/gui/list.c +++ b/apps/gui/list.c @@ -815,17 +815,21 @@ void simplelist_addline(int line_number, const char *fmt, ...) va_end(ap); } -static char* simplelist_static_getname(int item, void * data, char *buffer) +static char* simplelist_static_getname(int item, + void * data, + char *buffer, + size_t buffer_len) { - (void)data; (void)buffer; + (void)data; (void)buffer; (void)buffer_len; return simplelist_text[item]; } + bool simplelist_show_list(struct simplelist_info *info) { struct gui_synclist lists; struct viewport vp[NB_SCREENS]; int action, old_line_count = simplelist_line_count,i; - char* (*getname)(int item, void * data, char *buffer); + char* (*getname)(int item, void * data, char *buffer, size_t buffer_len); if (info->get_name) getname = info->get_name; else diff --git a/apps/gui/list.h b/apps/gui/list.h index 30de784687..8006847806 100644 --- a/apps/gui/list.h +++ b/apps/gui/list.h @@ -59,9 +59,11 @@ typedef enum themable_icons list_get_icon(int selected_item, void * data); * (The content of the buffer may not be used by the list, we use * the return value of the function in all cases to avoid filling * a buffer when it's not necessary) + * - buffer_len : length of the buffer * Returns a pointer to a string that contains the text to display */ -typedef char * list_get_name(int selected_item, void * data, char * buffer); +typedef char * list_get_name(int selected_item, void * data, + char * buffer, size_t buffer_len); /* * Voice callback * - selected_item : an integer that tells the number of the item to speak diff --git a/apps/gui/option_select.c b/apps/gui/option_select.c index 412a82d688..cee445d8c3 100644 --- a/apps/gui/option_select.c +++ b/apps/gui/option_select.c @@ -331,10 +331,12 @@ static int selection_to_val(struct settings_list *setting, int selection) return max- (selection * step); } static char * value_setting_get_name_cb(int selected_item, - void * data, char *buffer) + void * data, + char *buffer, + size_t buffer_len) { selected_item = selection_to_val(data, selected_item); - return option_get_valuestring(data, buffer, MAX_PATH, selected_item); + return option_get_valuestring(data, buffer, buffer_len, selected_item); } /* wrapper to convert from int param to bool param in option_screen */ |