Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
5a26c949
Commit
5a26c949
authored
Jan 14, 2009
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
oggvorbis: always allocate a tag object
Always allocate a new tag object before parsing the vorbis comments; free it when it turns out to be empty. This simplifies the code a bit.
parent
b5cadc9c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
8 deletions
+14
-8
oggvorbis_plugin.c
src/decoder/oggvorbis_plugin.c
+14
-8
No files found.
src/decoder/oggvorbis_plugin.c
View file @
5a26c949
...
...
@@ -37,6 +37,8 @@
#endif
/* HAVE_TREMOR */
#include <glib.h>
#include <assert.h>
#include <errno.h>
#include <stdlib.h>
#include <unistd.h>
...
...
@@ -140,11 +142,13 @@ static const char *VORBIS_COMMENT_TRACK_KEY = "tracknumber";
static
const
char
*
VORBIS_COMMENT_DISC_KEY
=
"discnumber"
;
static
bool
vorbis_parse_comment
(
char
*
comment
,
enum
tag_type
tag_type
,
struct
tag
**
tag
)
vorbis_parse_comment
(
struct
tag
*
tag
,
char
*
comment
,
enum
tag_type
tag_type
)
{
const
char
*
needle
;
unsigned
int
len
;
assert
(
tag
!=
NULL
);
switch
(
tag_type
)
{
case
TAG_ITEM_TRACK
:
needle
=
VORBIS_COMMENT_TRACK_KEY
;
...
...
@@ -158,10 +162,7 @@ vorbis_parse_comment(char *comment, enum tag_type tag_type,
len
=
strlen
(
needle
);
if
(
strncasecmp
(
comment
,
needle
,
len
)
==
0
&&
*
(
comment
+
len
)
==
'='
)
{
if
(
!*
tag
)
*
tag
=
tag_new
();
tag_add_item
(
*
tag
,
tag_type
,
comment
+
len
+
1
);
tag_add_item
(
tag
,
tag_type
,
comment
+
len
+
1
);
return
true
;
}
...
...
@@ -172,17 +173,22 @@ vorbis_parse_comment(char *comment, enum tag_type tag_type,
static
struct
tag
*
vorbis_comments_to_tag
(
char
**
comments
)
{
struct
tag
*
tag
=
NULL
;
struct
tag
*
tag
=
tag_new
()
;
while
(
*
comments
)
{
int
j
;
for
(
j
=
TAG_NUM_OF_ITEM_TYPES
;
--
j
>=
0
;)
{
if
(
vorbis_parse_comment
(
*
comments
,
j
,
&
tag
))
if
(
vorbis_parse_comment
(
tag
,
*
comments
,
j
))
break
;
}
comments
++
;
}
if
(
tag_is_empty
(
tag
))
{
tag_free
(
tag
);
tag
=
NULL
;
}
return
tag
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment