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:
parent
1b85f60ae0
commit
c23f56559f
1 changed files with 21 additions and 10 deletions
|
@ -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;
|
||||
|
@ -293,22 +293,33 @@ bool settings_write_config(char* filename)
|
|||
}
|
||||
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;
|
||||
}
|
||||
else
|
||||
{
|
||||
s = end + 1;
|
||||
val++;
|
||||
s = strtok_r(NULL,",",&end);
|
||||
}
|
||||
}
|
||||
while (*end++);
|
||||
}
|
||||
break;
|
||||
case F_T_BOOL:
|
||||
strcpy(value,*(bool*)settings[i].setting == true?"on":"off");
|
||||
|
|
Loading…
Reference in a new issue