summaryrefslogtreecommitdiffstats
path: root/firmware
diff options
context:
space:
mode:
authorJörg Hohensohn <hohensoh@rockbox.org>2005-01-03 20:23:42 +0000
committerJörg Hohensohn <hohensoh@rockbox.org>2005-01-03 20:23:42 +0000
commitdcdffe828c110adc42c08f32be4fe0acf70a86c1 (patch)
tree5b03be5da484aeb272a9c14bbb9f9779958e91ba /firmware
parent49efa8dc2b8864ddd153594d9d982806f94dcd49 (diff)
downloadrockbox-dcdffe828c110adc42c08f32be4fe0acf70a86c1.tar.gz
rockbox-dcdffe828c110adc42c08f32be4fe0acf70a86c1.tar.bz2
rockbox-dcdffe828c110adc42c08f32be4fe0acf70a86c1.zip
using a pointer instead of array dereferencing saves ~250 bytes
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@5529 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware')
-rw-r--r--firmware/common/dir.c40
1 files changed, 20 insertions, 20 deletions
diff --git a/firmware/common/dir.c b/firmware/common/dir.c
index 9f5f082b56..21c5f0100e 100644
--- a/firmware/common/dir.c
+++ b/firmware/common/dir.c
@@ -74,13 +74,19 @@ DIR* opendir(const char* name)
char* end;
struct fat_direntry entry;
int dd;
+ DIR* pdir = opendirs;
#ifdef HAVE_MULTIVOLUME
int volume;
#endif
+ if ( name[0] != '/' ) {
+ DEBUGF("Only absolute paths supported right now\n");
+ return NULL;
+ }
+
/* find a free dir descriptor */
- for ( dd=0; dd<MAX_OPEN_DIRS; dd++ )
- if ( !opendirs[dd].busy )
+ for ( dd=0; dd<MAX_OPEN_DIRS; dd++, pdir++)
+ if ( !pdir->busy )
break;
if ( dd == MAX_OPEN_DIRS ) {
@@ -89,26 +95,20 @@ DIR* opendir(const char* name)
return NULL;
}
- opendirs[dd].busy = true;
-
- if ( name[0] != '/' ) {
- DEBUGF("Only absolute paths supported right now\n");
- opendirs[dd].busy = false;
- return NULL;
- }
+ pdir->busy = true;
#ifdef HAVE_MULTIVOLUME
/* try to extract a heading volume name, if present */
volume = strip_volume(name, namecopy);
- opendirs[dd].volumecounter = 0;
+ pdir->volumecounter = 0;
#else
strncpy(namecopy,name,sizeof(namecopy)); /* just copy */
namecopy[sizeof(namecopy)-1] = '\0';
#endif
- if ( fat_opendir(IF_MV2(volume,) &(opendirs[dd].fatdir), 0, NULL) < 0 ) {
+ if ( fat_opendir(IF_MV2(volume,) &pdir->fatdir, 0, NULL) < 0 ) {
DEBUGF("Failed opening root dir\n");
- opendirs[dd].busy = false;
+ pdir->busy = false;
return NULL;
}
@@ -116,32 +116,32 @@ DIR* opendir(const char* name)
part = strtok_r(NULL, "/", &end)) {
/* scan dir for name */
while (1) {
- if ((fat_getnext(&(opendirs[dd].fatdir),&entry) < 0) ||
+ if ((fat_getnext(&pdir->fatdir,&entry) < 0) ||
(!entry.name[0])) {
- opendirs[dd].busy = false;
+ pdir->busy = false;
return NULL;
}
if ( (entry.attr & FAT_ATTR_DIRECTORY) &&
(!strcasecmp(part, entry.name)) ) {
- opendirs[dd].parent_dir = opendirs[dd].fatdir;
+ pdir->parent_dir = pdir->fatdir;
if ( fat_opendir(IF_MV2(volume,)
- &(opendirs[dd].fatdir),
+ &pdir->fatdir,
entry.firstcluster,
- &(opendirs[dd].parent_dir)) < 0 ) {
+ &pdir->parent_dir) < 0 ) {
DEBUGF("Failed opening dir '%s' (%d)\n",
part, entry.firstcluster);
- opendirs[dd].busy = false;
+ pdir->busy = false;
return NULL;
}
#ifdef HAVE_MULTIVOLUME
- opendirs[dd].volumecounter = -1; /* n.a. to subdirs */
+ pdir->volumecounter = -1; /* n.a. to subdirs */
#endif
break;
}
}
}
- return &opendirs[dd];
+ return pdir;
}
int closedir(DIR* dir)