Reduce stack usage in settings_write_config (by about 460 bytes). Should allow for a smaller ATA thread stack.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@12095 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Magnus Holmgren 2007-01-23 19:54:09 +00:00
parent 1b85f60ae0
commit c23f56559f

View file

@ -262,7 +262,7 @@ bool settings_write_config(char* filename)
{
int i;
int fd;
char value[MAX_PATH];
char value[MAX_FILENAME * 3]; /* More than enough for all current values */
fd = open(filename,O_CREAT|O_TRUNC|O_WRONLY);
if (fd < 0)
return false;
@ -287,27 +287,38 @@ bool settings_write_config(char* filename)
}
else
#endif
if (settings[i].cfg_vals == NULL)
if (settings[i].cfg_vals == NULL)
{
snprintf(value,MAX_PATH,"%d",*(int*)settings[i].setting);
}
else
{
char *s,*end;
char vals[MAX_PATH];
const char *s;
const char *end;
int val = 0;
strncpy(vals,settings[i].cfg_vals,MAX_PATH);
s = strtok_r(vals,",",&end);
while (s)
end = s = settings[i].cfg_vals;
do
{
while (*end != 0 && *end != ',')
{
end++;
}
if (val == *(int*)settings[i].setting)
{
strncpy(value,s,MAX_PATH);
strncpy(value, s, end - s);
value[end - s] = 0;
break;
}
val++;
s = strtok_r(NULL,",",&end);
else
{
s = end + 1;
val++;
}
}
while (*end++);
}
break;
case F_T_BOOL: