1
0
Fork 0
forked from len0rd/rockbox

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