forked from len0rd/rockbox
strtok:ing a copy of the parameter instead
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@687 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
40c6129c91
commit
a7b8b00fd4
1 changed files with 7 additions and 3 deletions
|
|
@ -29,7 +29,9 @@ static bool busy=false;
|
||||||
|
|
||||||
DIR* opendir(char* name)
|
DIR* opendir(char* name)
|
||||||
{
|
{
|
||||||
|
char namecopy[256];
|
||||||
char* part;
|
char* part;
|
||||||
|
char* end;
|
||||||
struct fat_direntry entry;
|
struct fat_direntry entry;
|
||||||
struct fat_dir* dir = &(thedir.fatdir);
|
struct fat_dir* dir = &(thedir.fatdir);
|
||||||
|
|
||||||
|
|
@ -48,9 +50,11 @@ DIR* opendir(char* name)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* fixme: strtok() is not thread safe, and fat_getnext() calls yield() */
|
strncpy(namecopy,name,sizeof(namecopy));
|
||||||
for ( part = strtok(name, "/"); part;
|
namecopy[sizeof(namecopy)-1] = 0;
|
||||||
part = strtok(NULL, "/")) {
|
|
||||||
|
for ( part = strtok_r(namecopy, "/", &end); part;
|
||||||
|
part = strtok_r(NULL, "/", &end)) {
|
||||||
int partlen = strlen(part);
|
int partlen = strlen(part);
|
||||||
/* scan dir for name */
|
/* scan dir for name */
|
||||||
while (1) {
|
while (1) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue