aboutsummaryrefslogtreecommitdiffstats
path: root/src/decoder/_flac_common.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2009-01-15 22:43:39 +0100
committerMax Kellermann <max@duempel.org>2009-01-15 22:43:39 +0100
commitf30adc352627d5aaaa933340dee24308e5920f15 (patch)
tree6126fe0c0ea493f80e0628384fd4a2f80caf8485 /src/decoder/_flac_common.c
parentccea3654945809932a7b85b365af11f91b5a1ded (diff)
downloadmpd-f30adc352627d5aaaa933340dee24308e5920f15.tar.gz
mpd-f30adc352627d5aaaa933340dee24308e5920f15.tar.xz
mpd-f30adc352627d5aaaa933340dee24308e5920f15.zip
flac: always allocate tag object
Free the tag object when it turns out to be empty. This simplifies several functions and APIs.
Diffstat (limited to '')
-rw-r--r--src/decoder/_flac_common.c22
1 files changed, 8 insertions, 14 deletions
diff --git a/src/decoder/_flac_common.c b/src/decoder/_flac_common.c
index ddce994de..2cf17ca40 100644
--- a/src/decoder/_flac_common.c
+++ b/src/decoder/_flac_common.c
@@ -99,10 +99,9 @@ static const char *VORBIS_COMMENT_TRACK_KEY = "tracknumber";
static const char *VORBIS_COMMENT_DISC_KEY = "discnumber";
static bool
-flac_copy_vorbis_comment(const
- FLAC__StreamMetadata_VorbisComment_Entry * entry,
- enum tag_type type,
- struct tag ** tag)
+flac_copy_vorbis_comment(struct tag *tag,
+ const FLAC__StreamMetadata_VorbisComment_Entry *entry,
+ enum tag_type type)
{
const char *str;
size_t slen;
@@ -123,10 +122,7 @@ flac_copy_vorbis_comment(const
if ((vlen > 0) && (0 == strncasecmp(str, (char *)entry->entry, slen))
&& (*(entry->entry + slen) == '=')) {
- if (!*tag)
- *tag = tag_new();
-
- tag_add_item_n(*tag, type,
+ tag_add_item_n(tag, type,
(char *)(entry->entry + slen + 1), vlen);
return true;
@@ -135,9 +131,9 @@ flac_copy_vorbis_comment(const
return false;
}
-struct tag *
-flac_vorbis_comments_to_tag(const FLAC__StreamMetadata * block,
- struct tag * tag)
+void
+flac_vorbis_comments_to_tag(struct tag *tag,
+ const FLAC__StreamMetadata *block)
{
unsigned int i, j;
FLAC__StreamMetadata_VorbisComment_Entry *comments;
@@ -146,13 +142,11 @@ flac_vorbis_comments_to_tag(const FLAC__StreamMetadata * block,
for (i = block->data.vorbis_comment.num_comments; i != 0; --i) {
for (j = TAG_NUM_OF_ITEM_TYPES; j--;) {
- if (flac_copy_vorbis_comment(comments, j, &tag))
+ if (flac_copy_vorbis_comment(tag, comments, j))
break;
}
comments++;
}
-
- return tag;
}
void flac_metadata_common_cb(const FLAC__StreamMetadata * block,