diff options
author | Jens Arnold <amiconn@rockbox.org> | 2005-09-02 16:50:51 +0000 |
---|---|---|
committer | Jens Arnold <amiconn@rockbox.org> | 2005-09-02 16:50:51 +0000 |
commit | ac50839423d12432f68b041c52deaa579c25d5c2 (patch) | |
tree | 08b8302ba15cfed841fdc40d8a26bab89eea40af /apps/filetypes.c | |
parent | 70542d7a0ccddc9d8c3af002fda9dddb0edb9c41 (diff) | |
download | rockbox-ac50839423d12432f68b041c52deaa579c25d5c2.tar.gz rockbox-ac50839423d12432f68b041c52deaa579c25d5c2.zip |
Optimised new file association handling. Fixed NULL pointer accesses. Const policed.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@7459 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/filetypes.c')
-rw-r--r-- | apps/filetypes.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/apps/filetypes.c b/apps/filetypes.c index 30ab2c34e5..721d5326ea 100644 --- a/apps/filetypes.c +++ b/apps/filetypes.c | |||
@@ -209,18 +209,20 @@ bool filetype_supported(int attr) | |||
209 | } | 209 | } |
210 | 210 | ||
211 | /* get the "dynamic" attribute for an extension */ | 211 | /* get the "dynamic" attribute for an extension */ |
212 | int filetype_get_attr(char* name) | 212 | int filetype_get_attr(const char* name) |
213 | { | 213 | { |
214 | int i; | 214 | int i; |
215 | char *cp; | 215 | const char *cp = strrchr(name,'.'); |
216 | |||
217 | if (!cp) /* no extension? -> can't be a supported type */ | ||
218 | return 0; | ||
219 | cp++; | ||
216 | 220 | ||
217 | for (i=0; i < cnt_exttypes; i++) | 221 | for (i=0; i < cnt_exttypes; i++) |
218 | { | 222 | { |
219 | if (exttypes[i].extension) | 223 | if (exttypes[i].extension) |
220 | { | 224 | { |
221 | cp=strrchr(name,'.'); | 225 | if (!strcasecmp(cp,exttypes[i].extension)) |
222 | if (cp) cp++; | ||
223 | if ((!strcasecmp(cp,exttypes[i].extension)) && (cp)) | ||
224 | { | 226 | { |
225 | return ((((unsigned long)exttypes[i].type - | 227 | return ((((unsigned long)exttypes[i].type - |
226 | (unsigned long)&filetypes[0]) / | 228 | (unsigned long)&filetypes[0]) / |