1
0
Fork 0
forked from len0rd/rockbox

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
This commit is contained in:
Nils Wallménius 2008-04-09 15:25:17 +00:00
parent ae64d2602b
commit 6848961aa5
22 changed files with 146 additions and 102 deletions

View file

@ -115,18 +115,19 @@ int _do_action(int action, char* str, int line)
last_char_index = c;
return 1;
}
char *list_get_name_cb(int selected_item,void* data,char* buf)
char *list_get_name_cb(int selected_item, void* data,
char* buf, size_t buf_len)
{
char *b = &buffer[do_action(ACTION_GET,0,selected_item)];
(void)data;
if (rb->strlen(b) >= MAX_PATH)
if (rb->strlen(b) >= buf_len)
{
char t = b[MAX_PATH-10];
b[MAX_PATH-10] = '\0';
rb->snprintf(buf,MAX_PATH,"%s ...",b);
b[MAX_PATH-10] = t;
char t = b[buf_len-10];
b[buf_len-10] = '\0';
rb->snprintf(buf , buf_len, "%s ...", b);
b[buf_len-10] = t;
}
else rb->strcpy(buf,b);
else rb->strncpy(buf, b, buf_len);
return buf;
}
char filename[MAX_PATH];