forked from len0rd/rockbox
MP3 metadata parser:
* Use ARRAYLEN() * id3_is_genre_string(): loop over the whole array instead of comparing a pointer to the first and last item of an array of pointers (fixes crash on Onda VX747) git-svn-id: svn://svn.rockbox.org/rockbox/trunk@22104 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
e454d88b88
commit
faf37f9d21
1 changed files with 9 additions and 4 deletions
|
@ -89,7 +89,7 @@ static const char* const genres[] = {
|
||||||
|
|
||||||
char* id3_get_num_genre(unsigned int genre_num)
|
char* id3_get_num_genre(unsigned int genre_num)
|
||||||
{
|
{
|
||||||
if (genre_num < sizeof(genres)/sizeof(char*))
|
if (genre_num < ARRAYLEN(genres))
|
||||||
return (char*)genres[genre_num];
|
return (char*)genres[genre_num];
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -97,8 +97,13 @@ char* id3_get_num_genre(unsigned int genre_num)
|
||||||
/* True if the string is from the "genres" array */
|
/* True if the string is from the "genres" array */
|
||||||
bool id3_is_genre_string(const char *string)
|
bool id3_is_genre_string(const char *string)
|
||||||
{
|
{
|
||||||
return ( string >= genres[0] &&
|
unsigned int i;
|
||||||
string <= genres[sizeof(genres)/sizeof(char*) - 1] );
|
|
||||||
|
for(i=0; i < ARRAYLEN(genres); i++)
|
||||||
|
if(genres[i] == string)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -445,7 +450,7 @@ static const struct tag_resolver taglist[] = {
|
||||||
{ "UFID", 4, 0, &parsembtid, false },
|
{ "UFID", 4, 0, &parsembtid, false },
|
||||||
};
|
};
|
||||||
|
|
||||||
#define TAGLIST_SIZE ((int)(sizeof(taglist) / sizeof(taglist[0])))
|
#define TAGLIST_SIZE ((int)ARRAYLEN(taglist))
|
||||||
|
|
||||||
/* Get the length of an ID3 string in the given encoding. Returns the length
|
/* Get the length of an ID3 string in the given encoding. Returns the length
|
||||||
* in bytes, including end nil, or -1 if the encoding is unknown.
|
* in bytes, including end nil, or -1 if the encoding is unknown.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue